Click here to Skip to main content
15,878,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Is there some way I can use Python to send data through a USB port and
control the data in real-time?. I have already implemented PyUSB and I can see and interact with the device.

(For instance, I can make a sound signal of a given specification and would like to send it through the USB and received it via a receive I built. How can I send the digitized form of this array through a USB port, and then convert it back by (demodulate?))

Second part is there way of detecting the unintentional electromagnetic emissions from the usb port?

Thanks!

What I have tried:

Hi

Is there some way I can use Python to send data through a USB port and
control the data in real-time?. I have already implemented PyUSB and I can see and interact with the device.  

(For instance, I can make a sound signal of a given specification and would like to send it through the USB and received it via a receive I built. How can I send the digitized form of this array through a USB port, and then convert it back by (demodulate?))

Second part is there way of detecting the unintentional electromagnetic emissions from the usb port?

Thanks!
Posted
Updated 8-May-17 12:24pm
Comments
[no name] 8-May-17 21:17pm    
Your question is too vague. If you are already using PyUSB to "interact" with your device then what is your problem? Do you have a technical document for the device which describes the interfaces it implements? Is the device something like an Arduino in which case it implements RS232 and you don't need PyUSB.

How and if you can do this depends entirely on the USB library you're using.

You also seem to misunderstand USB. That's not a port in the sense or a serial port, like you seem to think it is. USB is an expansion bus, not unlike the slots on the motherboard. The difference there being USB communicates via serial data lines instead of parallel lines.

There is no treating the USB "port" as if it was a serial port. You have to talk to a device on the bus, not to the bus itself. If your "receiver" is a USB device, great, it should be enumerated and listed as a device in the device manager of whatever O/S you're using.

Now, how you communicate with the device depends on the interface type of the device. If it shows up as a serial port, then you can talk to it using normal Serial I/O functions without worrying about USB at all. If it shows up as some other interface type, use the methods appropriate for that type.
 
Share this answer
 
v2
The USB port is a serial device. You access it using the pyserial package. Here is a link to the documentation.
https://pythonhosted.org/pyserial/

Search for "python USB examples" or "pyserial examples" and you will get lots of stuff to help you. As to "unintentional electromagnetic emissions", if your device(s) is FCC Class A or B certified in the US or equivalent in other countries you should not need to worry about it. If not you will need external test/detection equipment.
 
Share this answer
 
Comments
Dave Kreskowiak 8-May-17 18:29pm    
The USB port is a serial device

No it's not. It's an expansion BUS, not a port. In order to use normal serial I/O methods, the device you're trying to talk to must expose itself on the bus as a serial port device, COM1, COM2, ...

How you talk to the target device depends entirely on how that device exposes it's interface.
[no name] 8-May-17 21:14pm    
Dave Kreskowiak has pointed out a USB device is not RS232 unless the device has implemented this interface and few do. The op needs the technical specs for the device in question to see which interfaces are implemented.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900