Hi all,
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!
Hi all,
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!
This is classic article about Win32 serial communications: http://msdn.microsoft.com/en-us/library/ms810467.aspx
In C++:
CreateFile
("\\\\.\\COM39", ...)
SetCommState
SetCommTimeouts
ReadFile
, WriteFile
CloseHandle
There is also a full documentation on communication resources.
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 python it is as simple as importing pyserial and use its open() method (if you are using quite standard system, otherwise you have to adjust a number of parameters to match your environment of course).
EDIT:
As pointed out by Enrico, pyserial is not a default package in many distributions, so you have to install it by your own.
I suggest to install and use easy-install, by setuptools to handle your python addons packages.