How to communicate software (full duplex) with com port?

Status
Not open for further replies.
Level 23
Joined
Feb 6, 2014
Messages
2,466
Scenario:
I want to send a signal from the PC/Laptop into a hardware device via USB port. As far as I know, Processing and MATLAB can receive signal (analog) from the port and allow direct retrieval of the signal receive from that port but now I want it the other way around, I want to send a signal from the PC into the com port so that I can control the hardware device via PC software.

Any solution or thoughts? Share anything that is related here, I may find it useful.
 
If you want code, here's a sample of a serial communication class written for an Arduino on Windows.
If you want an application, you can use the Arduino IDE's Serial Monitor.

That was very useful indeed. Though I hate the lack of white space in the code.
In the ''Example main.cpp for Windows', it looks like he didn't write data on port, just read.
 
Yeah, I am not sure what's going on with the formatting on that page.

I myself use a slightly edited version of that code, I attached it in case it interests you (although there are only minor changes).
Note that if you are indeed talking with an Arduino, you will probably want to uncomment the 2 second wait (line 87), or put it in the code that uses the Serial class.

To write data just use the WriteData method. E.g. serial.WriteData("Hello", 5);.
 

Attachments

Status
Not open for further replies.
Back
Top