1

I have inverter DC/AC and I need to read the data. I have create the python code for communicate with rs232, but I need to create the same software for USB. I have connect the inverter at raspberry and the command: lsusb gives me this:

ID 0665:5161 Cypress Semiconductor USB to Serial

How to connect with this and send and receive data?

I tried this code:

import usb.core 
import usb.util 
import sys

dev = usb.core.find(idVendor=0x0665, idProduct=0x5161)
if dev.is_kernel_driver_active(0) is True: dev.detach_kernel_driver(0)

if dev is None: raise ValueError('Device not found')

dev.set_configuration() 
print "Device Found!"
dev.write(0x81,"QID",100)
byteread = dev.read(0x81,64) 
print byteread

But receive this error : usb.core.USBError: [Errno 110] Operation timed out

1

Is is a serial port already, hence the USB to serial designation. You can use the rs232 code on that port, which will have appeared somewhere in /dev/ with a name like ttyUSB0. If you check dmesg, you can see what name was assigned to the device. You won't be dealing with USB, the HID driver does that for you. Only the serial communication will have to be done in your software.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.