• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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.
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
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.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
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

  • Serial.zip
    2.3 KB · Views: 47
Status
Not open for further replies.
Top