RS485-RS232 through code

Switching back after a specified number of silent bits

The only way to do it AFAIK. The actual time used depends on the data and if there is any inter-byte delay on the data coming from the PC.

If there is then the delay has to be long enough to allow for that, then you may have a problem if the DriveManager responds too fast because you will still be waiting for the timout.

With direct port manipulation you should be able to transfer the bits in a timely fashion.

virtual COM port emulated by the ATmega16U2

So there is no RS232? Note, RS232 != serial, the two terms are kind of related but mean different things.

Sorry but this is getting too confusing, if the 16U2 talks USB there is no RS232 and you cannot get access to the actual bits of the data. Or is the 16U2 spitting out 5v serial that you want an Arduino to pass to the DriveManager.

If that's the case I'd just use a (software)serial port to accumulate the bytes then when the entire packet is received retransmit it to the DriveManager, get the response and send it to the PC.

EDIT: "virtual RS232 port (pin 0 on the arduino)"
OK, all the talk of RS232 and ATmega16U2s got me confused. We have 5v serial data on pin 0 so none of the above RS232 stuff is of any relevance and the ATmega16U2 is not relevent.

As I said I would read all the bytes and retransmit, unless the PC requires an immediate response that has to be the easiest way.


Rob