楼主最近还看过
Galil上位机软件的帮助文档里有一句话是针对message事件的
C++ | string Galil::message(int timeout_ms = 500) |
VB Event | Sub onMessage(ByVal message As String) |
C# Event | void onMessage(string message) |
Returns unsolicited messages (MGs) sent from the controller. Traffic transmitted by the controller to the host can be categorized into two primary groups: solicited and unsolicited. Solicited bytes are responses from commands sent by the host. For example, a solicited message is an encoder position string returned from g.command("TPX"). Unsolicited messages are transmitted asynchronously and could be output from MG commands from a running program aboard the controller, asynchronous error messages, trace (TR1) output, or responses from commands in a controller-side DMC program (TP, RP, etc).
For Ethernet connections, the library will automatically open two Ethernet handles on the controller. One TCP handle for command-and-response traffic, and one UDP handle for asynchrounous data, including messages (MGs).
C++: If the host-side message queue is empty, message() will wait up to timeout_ms for a message. If none occur within timeout_ms, a timeout error will be thrown. If there are already messages in the queue when message() is called, the function will immediately return the contents. If a zero timeout is specified, no errors will be thrown; message() will simply return the waiting queue (even if it is empty, ""). A -1 timeout will cause message() to block until a message is received.
COM: There are no timeouts for the onMessage event.
意思是对于c++如果超时就会抛出错误,下位机可以定时发送消息。这种方法可行吗。怎么检查这个抛出的错误。