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
  Convert even byte array to odd medatib531 1 231 Mar-17-2020, 02:48 AM
Last Post: scidam
  sorted function example mystery sabaidii2 4 247 Feb-10-2020, 09:37 AM
Last Post: DeaD_EyE
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 8 10,438 Feb-08-2020, 06:58 PM
Last Post: karkas
  Reading data from serial port as byte array vlad93 1 3,257 May-18-2019, 05:26 AM
Last Post: heiner55
  Read Byte Array from Zigbee coordinator using python jenkins43 3 723 Mar-26-2019, 03:03 PM
Last Post: micseydel
  Not able to Read byte Array From Wireless Coordinator jenkins43 0 424 Mar-18-2019, 07:05 AM
Last Post: jenkins43
  sorted object in list trois 2 512 Mar-04-2019, 09:12 AM
Last Post: trois
  [Help] sorted() in while loop with user's input() {Screenshot attached} vanicci 5 1,169 Aug-04-2018, 08:59 PM
Last Post: vanicci
  understanding sorted key parameter amirt 2 743 Jul-30-2018, 06:27 PM
Last Post: amirt
  Byte-Array okmog 3 1,382 Jun-13-2018, 03:19 PM
Last Post: DeaD_EyE

Forum Jump:


Users browsing this thread: 1 Guest(s)