c# - Serial coms; configuring rts -
I attempted to communicate with a win CE device via a rs485 connection configured as 8/1 I am doing and there is no handshaking. The problem is that there are two ways to act as a device's receiver or transmitter. To change between two methods of operation, I need to turn RTS ON / OFF. I have tried to do this, but till I use breakpoint, where RTS is enabled or disabled, I believe that one There is a problem of time and before I manage to send anything (the default mode is received) RTS is closed and closed. Try searching for Non and I tried Google, but so far I did not do anything. Can anyone help please?
This is my code:
Send public static usage Send_rs485 (byte [] toSend) {try {rs485.Write (ToSend, 0, ToSend Length); } Hold (Timeout Exceptions) {Message Box. Show ("COM port error"); } Return (0); } Private Zero Button 2_Click (Object Sender, EventArgs e) {if (COM_opened) {bool CTS = false; Rs485.RtsEnable = true; Rs485_Execute_cmd (ON_OFF); On_off =! On_off; Rs485.RtsEnable = false; } Other {message box. Show ("COM port not opened"); } //rs485.RtsEnable = false; }
The basic problem is that does not
Wait for IIRC to transmit all data. This is not a big problem when you are communicating properly, because it waits for the data to buffer (so you do not try to send 100 MIB / S), But if you read and write from other ordinary (in your case, the PIN is changing), this is a synchronization Jheshn creates problems.
This means that you have to wait - and the communication on the serial port is usually quite slow. How long do you have to wait, you should know the amount of data that you are sending and the baud rate example For, to send 12 bytes to 96 Baba ports, you have to wait 10 ms.
I'm not sure there is something that you can use to make it feel less dirty.
Comments
Post a Comment