- static uint8_t dri_syn6288_sendText(uint8_t backSound,uint8_t *text)
- {
- uint8_t tempBuf[DRI_SYN6288_BUFFER_LENGTH],i,crc = 0;
- uint16_t textLength; // 文本长度
- textLength = strlen((uint8_t*)text);
- /* 帧固定配置信息 */
- tempBuf[0] = 0xFD; // 帧头
- // tempBuf[1] = textLength >> 8; // 数据长度高字节
- tempBuf[1] = 0x00; // 数据长度高字节
- tempBuf[2] = (textLength & 0xff) + 3; // 数据长度低字节
- tempBuf[3] = 0x01; // 构造命令字:合成播放命令
- /* 字节高5位表示背景音乐,低3位表示编码格式 0是GB2312编码 */
- tempBuf[4] = 0x01|(backSound << 4); // 构造命令参数:背景音乐设定
- /* 校验码计算 */
- for(i = 0; i < 5; i++)
- {
- crc = crc ^ tempBuf[i]; // 对发送的字节进行异或校验
- }
- for(i = 0; i < textLength; i++)
- {
- crc = crc ^ text[i]; //对发送的字节进行异或校验
- }
- /* 发送数据 */
- memcpy(&tempBuf[5], text, textLength);
- tempBuf[5 + textLength] = crc;
- DRI_SYN6288_SEND_BUFFER(tempBuf,5 + textLength + 1); // 串口发送
- }
|