• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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: 45
Status
Not open for further replies.
Top