I am trying to use the RS-485 port on the BL2600 and I was having trouble getting it to send out the data intelligibly. The control word is 5 bytes long for what I’m trying to control, and I originally had it controlled by using 5 serEputc statements. I had to put a delay between each statement for the bytes to actually be read correctly.
I have seen that serEwrite will serve my purposes better (part of control word is an 0x00, so I couldn’t use serEputs), and I am not sure exactly about the best way to verify that the transmission is completed.
I have seen two methods in my research.
The BL2600 RS485 example shows:
while (serEgetc() == -1); //to wait for an echo
some websites and forums also list:
while( serEwrFree() < EOUTBUFSIZE);
while ( RdPortI(SESR) & 0x04 ); // wait for last byte to complete
and I’m not sure exactly what is the best way to do this.
In general, could anybody give a primer to RS485 on the BL2600 (or any of the single-board computers). I am quite confused why having the 5 serEputc statements in a row gave unintelligible characters without adding delays. I thought they put stuff into the transmit buffer, not INSTANTLY transmitted them. I thought the actual transmission would read the buffer at the appropriate baud-rate.
I am also confused why there must be some external way to verify that all of the bits have been transmitted. Unless something goes wrong and you absolutely MUST change back to Receive mode instantly, I couldn’t see why that wouldn’t be built in, or at least into some sort of ser485RxC() command that does the same thing as ser485Rx() but waits for the completion of transmission.
But anyway, the main thing would be, how best should I handle sending this 5 byte command and make sure everything was sent before switching back to receive mode?