這是我的 C 程式(在 Linux 中)的相關部分:
while (input != ' '){
write(serial_port, msg, sizeof(msg));
//1. here I would like to wait at least 100 us with the Tx line high
//2. followed by at least 8us with the Tx line low
//3. and then repeat the message
input = mygetch();
}
如您所見,在每次通過串口發送 msg 后,我想將 Tx 線設定為高電平 100 微秒,然后設定低電平 8 微秒,然后重復該訊息,直到用戶按下空格鍵。
我在 Linux 中使用 C 對串口進行這種控制嗎?
TIA 為您提供幫助。
uj5u.com熱心網友回復:
是的。不發送任何資料時串行線的默認狀態是“標記”(高電平,用于單端線)。要發送空格(低),請設定中斷位。清除中斷位以恢復空閑狀態。
正如評論中所指出的,tty 設備 ioctls TIOCSBRK 和 TIOCCBRK 可用于發送和清除中斷。
https://linux.die.net/man/4/tty_ioctl
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/465491.html
標籤:C 串行端口 linux-设备驱动程序 tty
上一篇:對話框中的粗體文本-DXL
下一篇:在c中乘以二維矩陣時面臨的問題
