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
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 7 396 Sep-12-2019, 11:19 PM
Last Post: newbieAuggie2019
  Reading data from serial port as byte array vlad93 1 1,289 May-18-2019, 05:26 AM
Last Post: heiner55
  Read Byte Array from Zigbee coordinator using python jenkins43 3 404 Mar-26-2019, 03:03 PM
Last Post: micseydel
  Not able to Read byte Array From Wireless Coordinator jenkins43 0 251 Mar-18-2019, 07:05 AM
Last Post: jenkins43
  sorted object in list trois 2 327 Mar-04-2019, 09:12 AM
Last Post: trois
  [Help] sorted() in while loop with user's input() {Screenshot attached} vanicci 5 878 Aug-04-2018, 08:59 PM
Last Post: vanicci
  understanding sorted key parameter amirt 2 543 Jul-30-2018, 06:27 PM
Last Post: amirt
  Byte-Array okmog 3 1,011 Jun-13-2018, 03:19 PM
Last Post: DeaD_EyE
  4 byte hex byte swap from binary file medievil 7 6,956 May-08-2018, 08:16 AM
Last Post: killerrex
  converting array of things to byte stream to send bigjoey 2 689 Feb-27-2018, 12:56 PM
Last Post: bigjoey

Forum Jump:


Users browsing this thread: 1 Guest(s)