开发者

How to open and write/read to a USB CDC "serial" device on Windows, Linux, OS X?

I've got an Atmel AVR A90USBxxxx device that I have configured to "talk USB" via CDC. It's designed to take input from a Host computer, running Windows, Linux, or OS X.

I'm under the impression that Linux and OS X will immediately recognize this CDC device, and with a simple .inf a Windows machine can be told my VID/PID should be opened as a CDC device using usbser.sys.

My question is once the OS has opened this USB device as a serial device, how can I programmatically read and write to that port (for each of the 3 OS's listed but开发者_JS百科 most detail is needed for Windows as I'm completely unfamiliar there)

Thanks


The answer really depends on what programming language you intend to use. Without knowing what language you intend to use, I can't tell you exactly how to do it, but I can point you in the right direction.

For prototyping, I recommend using Python with the PySerial module. It's very easy to set up and quickly write a functional prototype. Python will run on Windows, Linux, and OS X. That way you only need to write the serial communication code once and you can test on all of your platforms.

The PySerial documentation contains some examples for how to read and write to the port.

If Python doesn't work for you in production, I would still recommend sticking with a programming language that has a cross-platform serial port library if possible.

Here's a question that was asked already about a cross-platform serial port library for C: C: cross-platform RS-232 serial library?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜