Hello,
I am using a device from which information are gathered via a RS-232 port on a PC (19200 bps).
The software running on the PC polls the device to retrieve the data every 200 ms.
PC: Value1 poll
Device: Current value1
PC: Value2 poll
Device: Current value2
PC: Value1 poll
Device: Current value1
loop...
I can't modify the software but I need to gather the other information New_Value which will be processed and displayed on a LCD by an Arduino module.
The idea is to insert the Arduino in the serial line and ask it to repeat in both ways the serial exchanges between the PC and the device, and to insert a new request between two polls.
PC: Value1 poll
Arduino: read "Value1 poll" from PC
Arduino: send "Value1 poll" to the device
Device: Current value1
Arduino: read "Current value1" from the device
Arduino: send "Current value1" to the PC
Arduino: send "New_Value poll" to the device
Arduino: read "Current New_Value" from the device and displays it on a LCD
PC: Value2 poll
Arduino: read "Value2 poll" from PC
Arduino: send "Value2 poll" to the device
Device: Current value2
Arduino: read "Current value2" from the device
Arduino: send "Current value2" to the PC
loop...
Is this feasable with an Arduino (probably with NewSoftSerial and a MAX232)?
Hi,
I would really like to use a Pro Mini that I have in stock.
By the way, reliability is not an issue as the data are polled every 200 ms, I can miss one or two without consequences.
That works pretty well as soons as only one of the two blocks is uncommented, and I can either monitor the data sent by the PC or by the device with the regular serial console.
Serial console with block 1 uncommented (data poll):
IF;
IF;
IF;
Serial console with block 2 uncommented (device's answer):
But as soons as I uncomment the other block the program does not work anymore. The data displayed comports specials characters and I suspect them to make the whole program not working:
Hi,
Yes, all the code is here.
I am using a 3rd serial port because I wanted to use the integrated one for debugging purpose (which looks mandatory ;))
I use readStringUntil (Stream.readStringUntil() - Arduino Reference), as the semi-colon is a delimiter.
The correct exchanges between both devices is :
IF; (data poll)
IF00124895000+000000300000; (answer)
str and str2 content the data exchanged, and this data will be processed afterward.
For the moment, I am just trying to set up the dialog between the PC and the Device by simply forwarding the requests and the answers.
One via a real RS232 interface (remember, the old DB9 plugs )
One via an USB port, to the FTDI integrated chipset.
Your last sentence point me one the right direction, it seems that only one interrupt can be handeled whatever the number of SoftwareSerial declarations.
I will give a try using the integrated serial port and only one SoftwareSerial instance.
Hi,
I have tried exactly the same pattern and same code but with one SoftwareSerial instance and the integrated serial port, it works like a charm !!!
I guess I was encountering a kinf of interrupt issue, the running SoftwareSerial call was disturbed as soon as the other one received some data.
The exchanges between the PC and the device are now forwarded both ways, next step is to process the data.
Thank you very much for your support.