简体   繁体   中英

Serial Interface Communication and Spaces

I want to send two commands to a µC per USB. One of this commands is be succesful transmitted. The other resoltues only in a "Invalid Command"-Message from the µC.

Both Commands exists and are correctly dialed. I had proff them by using a other program and in the SourceCode of the µC.

I send the commands by this codelines:

if(!WriteFile(hSerial, c_command1, sizeof(c_command1), &dwBytesWrite, NULL)) 
{ 
    cerr << "Error: Reading failure" << endl; 
}

My first command (that who works): START\\r\\n

The second command: PARAM NR 5\\r\\n

The \\r\\n means a CR-LF which means "Command is over".

I think the communication has some problem with the space. Can anybody help me? A hint what I should change?

-casisto

Your tests seem to indicate that the COM port output is working. One possible problem is that the sizeof your command strings includes their terminating null so you are sending the terminating null along with each command. The µC may not like that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM