I have a problem while using serial communication for USB CDC. I'm working on embedded STM microcontrollers and i wanted to pass binary data with pySerial.
I wanted to send binary codes directly but I am blocked by this 0x00 .. My problem is when i want to send 0x00 byte, the next bytes seems to be ignored..
Here's the python script:
towrite = [ 0xFF, 0xx00 \xFF ]
nbSend = s.write(b'\xFF\x00\xFF')
print(nbSend) #Displaying 3 here, that means 3 bytes are successfully sended
Then the embedded script:
//Interrupt function that receive the data from serial com
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
USBD_CDC_ReceivePacket(&hUsbDeviceFS);
char buffer[64];
sprintf(buffer,"Length=%lu / Word=%c%c%c ",(unsigned long)*Len,Buf[0],Buf[1],Buf[2]);
debugPrintln(&huart2, buffer) //Function to print on serial to debug
//Here that print "Length=3 / Word=ΓΏ "
return (USBD_OK);
/* USER CODE END 6 */
}
As you can see, the second and ultimate characters (0x00, 0xFF) are not taken into account even if the number of bytes received is good ... Any advice?