简体   繁体   English

串行接口通信和空间

[英]Serial Interface Communication and Spaces

I want to send two commands to a µC per USB. 我想将两个命令发送到每个USB的µC。 One of this commands is be succesful transmitted. 该命令之一是成功发送的。 The other resoltues only in a "Invalid Command"-Message from the µC. 其他仅在µC的“无效命令”消息中解决。

Both Commands exists and are correctly dialed. 这两个命令都存在并且已正确拨打。 I had proff them by using a other program and in the SourceCode of the µC. 我通过使用其他程序并在µC的SourceCode中对它们进行配置。

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 我的第一个命令(谁起作用):START \\ r \\ n

The second command: PARAM NR 5\\r\\n 第二条命令:PARAM NR 5 \\ r \\ n

The \\r\\n means a CR-LF which means "Command is over". \\ r \\ n表示CR-LF,表示“命令已结束”。

I think the communication has some problem with the space. 我认为交流方面存在一些问题。 Can anybody help me? 有谁能够帮助我? A hint what I should change? 提示我应该改变什么?

-casisto -casisto

Your tests seem to indicate that the COM port output is working. 您的测试似乎表明COM端口输出正在工作。 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. 一个可能的问题是命令字符串的大小包括它们的终止null,因此您将随每个命令一起发送终止null。 The µC may not like that. µC可能不喜欢这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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