mirror of
https://git.code.sf.net/p/newrpl/sources
synced 2024-11-16 19:51:25 +01:00
Fixed usb_sendata on PC side to be portable.
This commit is contained in:
parent
81a336c0fd
commit
808e574e11
1 changed files with 12 additions and 11 deletions
|
@ -473,7 +473,7 @@ int usb_transmitdata(BYTEPTR data,BINT size)
|
|||
BYTEPTR buf;
|
||||
|
||||
// ONLY ALLOCATE MEMORY FOR DATA BLOCKS LARGER THAN 1 PACKET
|
||||
if(size>RAWHID_TX_SIZE-8) buf=simpmallocb(size+8);
|
||||
if(size>RAWHID_TX_SIZE-8) buf=simpmallocb(size+9);
|
||||
else buf=__usb_txtmpbuffer;
|
||||
|
||||
if(!buf) return 0; // FAILED TO SEND - NOT ENOUGH MEMORY
|
||||
|
@ -482,23 +482,24 @@ int usb_transmitdata(BYTEPTR data,BINT size)
|
|||
|
||||
__usb_count[1]=size+8;
|
||||
|
||||
buf[0]=USB_BLOCKSTART_MARKER; // START OF BLOCK MARKER
|
||||
buf[1]=size&0xff;
|
||||
buf[2]=(size>>8)&0xff;
|
||||
buf[3]=(size>>16)&0xff;
|
||||
buf[0]=0; // REPORT ID
|
||||
buf[1]=USB_BLOCKSTART_MARKER; // START OF BLOCK MARKER
|
||||
buf[2]=size&0xff;
|
||||
buf[3]=(size>>8)&0xff;
|
||||
buf[4]=(size>>16)&0xff;
|
||||
|
||||
WORD crc=usb_crc32(data,size);
|
||||
|
||||
buf[4]=crc&0xff;
|
||||
buf[5]=(crc>>8)&0xff;
|
||||
buf[6]=(crc>>16)&0xff;
|
||||
buf[7]=(crc>>24)&0xff;
|
||||
buf[5]=crc&0xff;
|
||||
buf[6]=(crc>>8)&0xff;
|
||||
buf[7]=(crc>>16)&0xff;
|
||||
buf[8]=(crc>>24)&0xff;
|
||||
|
||||
memmoveb(buf+8,data,size);
|
||||
memmoveb(buf+9,data,size);
|
||||
|
||||
|
||||
|
||||
err=hid_write(__usb_curdevice,__usb_bufptr[1],__usb_count[1]);
|
||||
err=hid_write(__usb_curdevice,__usb_bufptr[1],__usb_count[1]+1);
|
||||
|
||||
if(buf!=__usb_txtmpbuffer) simpfree(buf);
|
||||
|
||||
|
|
Loading…
Reference in a new issue