2012-12-14 2 views
1

나는 공급 업체 ID : 0461 및 제품 ID : 0020을 사용하는 usb 릴레이 회로를 가지고 있습니다.이 장치를 pyusb를 통해이 장치와 통신하려고했으나 장치를 연결할 수는 있지만 연결할 수 없습니다 모든 명령을 보내면 항상 사용 중 오류가 발생합니다.bic을 통해 pic18f2550 릴레이 circuti에 명령 보내기

어떻게 우분투에서 bash 또는 pyusb를 통해이 회로에 명령을 보낼 수 있습니까?

내 파이썬 코드는

import usb.core 
import usb.util 
import struct 
dev = usb.core.find(idVendor=0x0461, idProduct=0x0020) 
if dev is None: 
    raise ValueError('Device not found') 
cfg = dev[0] 
intf = cfg[(0,0)] 

ep = usb.util.find_descriptor(
    intf, 
    custom_match = \ 
    lambda e: \ 
     usb.util.endpoint_direction(e.bEndpointAddress) == \ 
     usb.util.ENDPOINT_OUT 
) 
assert ep is not None 

buff = [0x80] 
ep.write(buff) 

내 lsusb -v 세부 사항입니다

Bus 003 Device 002: ID 0461:0020 Primax Electronics, Ltd 
Device Descriptor: 
    bLength    18 
    bDescriptorType   1 
    bcdUSB    1.10 
    bDeviceClass   0 (Defined at Interface level) 
    bDeviceSubClass   0 
    bDeviceProtocol   0 
    bMaxPacketSize0  64 
    idVendor   0x0461 Primax Electronics, Ltd 
    idProduct   0x0020 
    bcdDevice   1.00 
    iManufacturer   1 SAC 
    iProduct    2 ----arena---- 
    iSerial     0 
    bNumConfigurations  1 
    Configuration Descriptor: 
    bLength     9 
    bDescriptorType   2 
    wTotalLength   41 
    bNumInterfaces   1 
    bConfigurationValue  1 
    iConfiguration   0 
    bmAttributes   0xc0 
     Self Powered 
    MaxPower    100mA 
    Interface Descriptor: 
     bLength     9 
     bDescriptorType   4 
     bInterfaceNumber  0 
     bAlternateSetting  0 
     bNumEndpoints   2 
     bInterfaceClass   3 Human Interface Device 
     bInterfaceSubClass  0 No Subclass 
     bInterfaceProtocol  0 None 
     iInterface    0 
     HID Device Descriptor: 
      bLength     9 
      bDescriptorType  33 
      bcdHID    1.00 
      bCountryCode   0 Not supported 
      bNumDescriptors   1 
      bDescriptorType  34 Report 
      wDescriptorLength  32 
     Report Descriptors: 
      ** UNAVAILABLE ** 
     Endpoint Descriptor: 
     bLength     7 
     bDescriptorType   5 
     bEndpointAddress  0x81 EP 1 IN 
     bmAttributes   3 
      Transfer Type   Interrupt 
      Synch Type    None 
      Usage Type    Data 
     wMaxPacketSize  0x0040 1x 64 bytes 
     bInterval    1 
     Endpoint Descriptor: 
     bLength     7 
     bDescriptorType   5 
     bEndpointAddress  0x01 EP 1 OUT 
     bmAttributes   3 
      Transfer Type   Interrupt 
      Synch Type    None 
      Usage Type    Data 
     wMaxPacketSize  0x0040 1x 64 bytes 
     bInterval    1 
Device Status:  0x0001 
    Self Powered 
+0

MODE Sudo로 실행 해 보았습니까? 그렇다면 /etc/udev/rules.d에있는 UDEV 규칙 일 수도 있습니다. – ServerMonkey

답변

0

하면 /etc/udev/rules.d 파일에 다음과 같은 것을 설정해보십시오!

SUBSYSTEM = "usb_device"ACTION = "추가", GOTO는 = "device_rules_end" sysfs를을! {idVendor} == "1,532"sysfs를 {idProduct} == "0017", 심볼릭 링크 + = "mydevice"= "0666"OWNER = ""GROUP = "루트" LABEL = "device_rules_end"

+0

시도했지만 여전히 운이 없습니다. –

+0

로그에서 시스템이 예상 된 장치 세부 정보를 볼 수 있는지 확인 했습니까? – ServerMonkey

+0

lsusb -v exports; https://docs.google.com/document/d/1Vv64TrDVdGdXhpxmbv2wMi8fwPia1wep5cDUr0krdwA/edit –

관련 문제