RS232不能設定stop 位元為1.5 byte |
尚未結案
|
plihui
初階會員 發表:88 回覆:96 積分:41 註冊:2003-07-03 發送簡訊給我 |
void __fastcall TForm1::Button1Click(TObject *Sender) { //選擇使用的port: com1 或 com2 char *Com_port; DCB dcb; String Com_name="COM" IntToStr(CommSelect->ItemIndex 1); Com_port=Com_name.c_str(); hComm=CreateFile(Com_port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0 ,0); if ( hComm == INVALID_HANDLE_VALUE) { MessageBox(0, "開啟錯誤的通訊阜!!!","錯誤的通訊阜", MB_OK); return; } // 將dcb位置傳入,已設定通訊參數 GetCommState(hComm,&dcb); dcb.BaudRate = CBR_9600; dcb.ByteSize = 8; dcb.Parity=NOPARITY; dcb.StopBits=ONE5STOPBITS; ^^^^^^^^^^^^^^^^^ if( !SetCommState( hComm, &dcb) ) { MessageBox(0, "通訊參數設定失敗", "Setting Error", MB_OK); CloseHandle(hComm); return; } }結果出現"通訊參數設定失敗"的訊息??? 是程式哪裡出問題?還是RS232不能設定stop 位元為1.5 byte? ps: 我的作業系統為window XP |
㊣
版主 發表:261 回覆:2302 積分:1667 註冊:2005-01-04 發送簡訊給我 |
|
plihui
初階會員 發表:88 回覆:96 積分:41 註冊:2003-07-03 發送簡訊給我 |
|
暗黑破壞神
版主 發表:9 回覆:2301 積分:1627 註冊:2004-10-04 發送簡訊給我 |
|
plihui
初階會員 發表:88 回覆:96 積分:41 註冊:2003-07-03 發送簡訊給我 |
|
暗黑破壞神
版主 發表:9 回覆:2301 積分:1627 註冊:2004-10-04 發送簡訊給我 |
|
plihui
初階會員 發表:88 回覆:96 積分:41 註冊:2003-07-03 發送簡訊給我 |
http://www.lammertbies.nl/comm/info/RS-232_specs.html
找到了.... [原文]
Stop bits
Suppose that the receiver has missed the start bit because of noise on the transmission line. It started on the first following data bit with a space value. This causes garbled date to reach the receiver. A mechanism must be present to resynchronize the communication. To do this, framing is introduced. Framing means, that all the data bits and parity bit are contained in a frame of start and stop bits. The period of time lying between the start and stop bits is a constant defined by the baud rate and number of data and parity bits. The start bit has always space value, the stop bit always marking value. If the receiver detects a value other than marking when the stop bit should be present on the line, it knows that there is a synchronization failure. This causes a framing error condition in the receiving UART. The device then tries to resynchronize on new incomming bits. For resynchronizing, the receiver scans the incomming data for valid start and stop bit pairs. This works, as long as there is enough variation in the bit patterns of the data words. If data value zero is sent repeatedly, resynchronization is not possible for example. The stop bit identifying the end of a data frame can have different lengths. Actually, it is not a real bit but a minimum period of time the line must be idle (marking state) at the end of each word. On PC's this period can have three lengths: the time equal to 1, 1.5 or 2 bits. 1.5 bits is only used with data words of 5 bits length and 2 only for longer words. A stop bit length of 1 bit is possible for all data word sizes.
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |