簡體   English   中英

在Linux中使用c ++進行串行通信

[英]serial communication using c++ .in Linux

我可以串行發送1個字節的char類型數據。 現在我一直在發送浮點型數據。 這是我用於串行發送數據的代碼。

fd = open("/dev/ttyO1", O_RDWR | O_NOCTTY);
char byte_out[] = {0x47};
write(fd, byte_out, strlen(byte_out)+1);

我如何串行寫入(或發送)浮點型數據。 請幫我 。 提前致謝 。

沒什么不同..並且您需要放置正確大小的浮點類型..

fd = open("/dev/ttyO1", O_RDWR | O_NOCTTY);
float float_out[] = {1.2342};
write(fd, (void *) float_out, sizeof(float));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM