Reading binary commands using PC comm port and Windows OS on XStream radio modems

ClearCTSEvent(); // Make sure there are no pending events
ClearCTSEvent(); // Make double sure there are no pending events 
DeassertRTS(); // Assert binary command mode 
bCmd |= 0x80; // Set msb for reading the register 
WriteData(bCMD); // Send binary command 
WaitForCTSEvent(); // CTS will frame the response 
AssertRTS(); // De-assert binary command mode 
ReadData(); // Retrieve the binary response from the comm port buffer

Here are some guidelines to keep in mind when developing applications to use the binary command interface:
  1. During a binary read, the CTS signal is used to frame the binary response. We recommend monitoring the CTS line to differentiate the response from the binary command from data coming out the serial port that may have been received over-the-air.
  2. When doing a read, be sure to clear the CTS event twice before asserting the binary command mode. This can be cleared by reading it using the WaitCommEvent (see MSDN).
  3. Set RTS using EscapeCommFunction (see MSDN).
  4. CTS will frame the response so wait for a CTS event before de-asserting the command mode.
  5. If using a USB serial driver, note that it is not as responsive as a mother board serial driver. This is because the USB protocol adds additional latency because it is time slot driven (TDMA). As a result, the driver cannot get immediate responses to queries but must wait for the USB to return the result.
  6. With that in mind, don't poll the driver rapidly (every millisecond). Try to avoid doing single character events but design comm port functions to operate on larger blocks of data when possible.(I.E. Try to read blocks of data from the comm port, not just one character. This is more efficient for the driver and the USB bus.)
  7. Use the WaitCommEvent with timeouts to trigger on events instead of using a port polling mechanism. This programming technique allows the driver the time it needs to respond and keeps the application from overloading it with requests.

Following these guidelines will facilitate the implementation of binary commands on a PC platform using the windows operating system.

Last updated: Aug 08, 2017

Recently Viewed Articles

No recently viewed articles