From what you say, it seems that the communication is Q&A type (you send a command and the equipmant responds to it). In this case I suggest you set a time-out limit for serial communication to a appropriate time for the device to respond, and after ComRd terminates verify if the amount of bytes received is equal to what expected: if not, either the device is off or there is a problem in communication. In both cases your application must react someway.
So, in pseudo-code (you'll have to detail a bit):
//----------------------------------------
// Configure the port for communication
//----------------------------------------
OpenComConfig
SetComTime
//----------------------------------------
// Establish communication
//----------------------------------------
ComWrt ("atestequipment\r")
ComRd (buf) // "Buf" is the string into which device response is stored
// Test lenght of response
if ( strlen (buf) < expected lenght) error routine
// Test response
it depends on equipment protocol
if the device responds with a fixed string, you can simply use
if (strcmp (buf, "expected string")) error string
if the protocol is more complicated or variable you'll have to break down the answer and test individual fields
//----------------------------------------
// Communicate with the equipment
//----------------------------------------
// Issue command
sprintf (buf, ..., ...) // Format comand to issue according to device protocol
ComWrt (buf)
ComRd (buf)
// Again, test response lenght
if (strlen (buf) < 16) error routine
// Test response
for (i = 0; i < 16; i++) { // For every byte
// Decode individual bits by testing with the "&" operator: if =0 bit off else bit on
bit0 = buf[i] & 0x1 ? 1 : 0
bit1 = buf[i] & 0x2 ? 1 : 0
...
bit4 = buf[i] & 0x10 ? 1 : 0
bit5 = buf[i] & 0x20 ? 1 : 0
...
}
Hope this helps
Roberto