Linux串口-wrtie()字节通过串口发送到目标设备

Linux serial port - wrtie( ) byte to the target device through serial port

unsigned char cmd[] = {'A', 'T', '+', "0x07", "0x08", 'D', 'F', "0xA6"};

要将此命令写入我的目标设备,我希望写入字节

41 54 2b 07 08 44 46 A6 

因此。

然而,写入设备的实际字节数为

41 54 2b b8 bb 44 46 be

并且在

处明显错误
0x07 0x08 0xA6

我希望在上面的示例中如何写入字节?

-----写函数------

void WriteToDevice(){
unsigned char cmd[]={'A', 'T', '+', "0x07", "0x08", 'D', 'F', "0xA6"};
int n = write(fd,&cmd,8);

for(p=0;p<8;p++){
    printf("bytes written: %02x \n", cmd[p]);
}

if(n<0){
    printf("write error \n");
}
else{
    printf("%d bytes written \n", n);
}

};

编译器警告

warning: (near initialization for ‘cmd[3]’) [enabled by default]
warning: initialization makes integer from pointer without a cast [enabled by default]

而不是 "0x07", "0x08",等等,使用 '\x07', '\x08',等等