按网上教程,用cubeMx写了一个通过rs485发送16进制数据的程序
- HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, GPIO_PIN_SET);
- uint16_t TxByte = 0x01 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte =0x06 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte =0x00 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte = 0x42 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte = 0x03 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte = 0xE8 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte = 0x29 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- TxByte = 0x60 ;
- HAL_UART_Transmit( huart2, (uint8_t *) TxByte, 1, 0xFF);
- HAL_Delay(1000);
然后烧录上之后理论上发送的是01 06 00 42 03 E8 29 60 ,结果用串口助手试了下收到的是81 06 00 42 03 E8 A9 60
请问是怎么回事……