I need to read the serial port from windows, using either Python or C++. What API/Library should I use? Can you direct me to a tutorial? Thanks!
1) Click Start. 2) Click Control Panel in the Start menu. 3) Click Device Manager in the Control Panel. 4) Click + next to Port in the Device Manager to display the port list.
In Serial Port Reader go to the “Main menu”, choose “Session -> New session”. Alternately, you can click on the “New” icon on the main toolbar or press “Ctrl + N”. This invokes the “New monitoring session” screen. Terminal view – all received data is displayed in ASCII characters on a text console.
Transmitting Data: Firstly, we need to include the serial library. We can then declare an instance of the serial port and add the SerialPort, baudRate and timeOut parameters , I'm using serial0, 115200 and 0.050. To find your Pi serial port use the command 'lsdev'. In my case, my serial port was serial0.
In python you've excellent package pyserial that should be cross-platform (I've used only in GNU/Linux environment).
Give it a look, it's very simple to use but very powerful!
Of course examples are provided!
By the way, if it can be useful here you can find a project of mine which use pyserial, as an extended example.
In C++:
CreateFile
("\\\\.\\COM39", ...)
SetCommState
SetCommTimeouts
ReadFile
, WriteFile
CloseHandle
There is also a full documentation on communication resources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With