Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Byte array is sorted when sending via USB
#1
I'm new to the forum and new to Python as well

I'm using Python 3.7.0 and Pywinusb 0.4.2 to send raw data to an HID device.

import pywinusb.hid as hid

def readData(data):
    print(data)

device = hid.HidDeviceFilter(vendor_id=0xXXXX, product_id=0xXXXX).get_devices()[0]
if not device:
    print ("No device found")
else:
    print(device)
    device.open()
    report = device.find_output_reports()
    print(report)
    print(report[0])
    buffer=[0x00]*65 #USB packet size
    buffer[0]=0x00 #report id
    buffer[1]=0x0A
    buffer[2]=0x2F
    buffer[3]=0x02
    buffer[4]=0x03
    buffer[5]=0x01
    report[0].set_raw_data(buffer)
    report[0].send()
    device.set_raw_data_handler(readData)
    device.close()
The HID device receives the data, I already confirmed this.

My problem is that somewhere the byte array gets sorted from minor to major. I already confirmed this as well

Any ideas ?


Thank you

David DLC
Quote
#2
You are using a list which is mutable. Try to send this: buffer = b'\x00\x0A\x2F\x02\x03\x01'
You should see struct module.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Byte string catenation inefficient in 3.7? RMJFlack 13 339 Aug-18-2019, 05:19 AM
Last Post: RMJFlack
  raw byte of integer jonnin 4 184 Jul-22-2019, 03:48 AM
Last Post: jonnin
  HELP: String of Zero's and One's to binary byte schwasskin 1 1,130 May-19-2019, 07:31 AM
Last Post: heiner55
  Reading data from serial port as byte array vlad93 1 793 May-18-2019, 05:26 AM
Last Post: heiner55
  g Null Byte using DictReader eshwinsukhdeve 13 481 May-15-2019, 08:50 AM
Last Post: buran
  HELP! sending data to MySQL Slei 2 281 May-09-2019, 08:29 AM
Last Post: Slei
  charmap codec can't decode byte error with gzipped file in python bluethundr 2 226 Apr-30-2019, 12:26 PM
Last Post: bluethundr
  sending html file in email santoshi 3 337 Apr-05-2019, 03:59 PM
Last Post: nilamo
  Read Byte Array from Zigbee coordinator using python jenkins43 3 297 Mar-26-2019, 03:03 PM
Last Post: micseydel
  Not able to Read byte Array From Wireless Coordinator jenkins43 0 194 Mar-18-2019, 07:05 AM
Last Post: jenkins43

Forum Jump:


Users browsing this thread: 1 Guest(s)