1
votes

I want to get Arduino code onto a virtual serial port instead of the actual Arduino. The IDE sends binary code to the Arduino through the COM port which in this case will be a virtual COM port and no Arduino.

I want to read and store the code that is being uploaded into the COM port. I have tried several Java libraries (RXTX, jSSC and the gnu.io), but I can't read what's on the COM port as it will always give the exception that it is being used by another application (which is the Arduino IDE). So I want to upload Arduino code on a virtual port and on the other end of this port there is a Java application which can read what is being sent to this port.

Related question: Upload Arduino code on virtual serial port through Arduino IDE.

If a solution is available or easier in any other language I'm open.

1

1 Answers

0
votes

At the moment it sounds like you're trying to read and write to the same port with two applications, and expect to get the output of one on the input of the other - it doesn't quite work like that. Think of the COM port as one end of the stream you can read and write to, rather than the stream itself - hence when you tell more than one process (in your case the Arduino and your Java program) to read / write both from the same end, it will fail.

I believe what you're after is a null-modem emulator. Use something like com0com to create a pair of virtual COM ports, where the input on one will appear as the output on another (and vice versa.) You can then go about things relatively normally, writing to one COM port in the pair with the Arduino IDE and listening on the other COM port with your Java program, using jssc, RXTX or any other serial library you choose.