Generic driver for the RWD RFID Modules from IB Technology.

Dependents:   RSEDP_DPDemo

Revision:
1:e96aaf4d5c55
Parent:
0:a893227b988a
Child:
2:37fafd1e1a20
--- a/RWDModule.cpp	Mon Jul 12 09:31:45 2010 +0000
+++ b/RWDModule.cpp	Tue Jul 13 10:37:26 2010 +0000
@@ -54,6 +54,7 @@
 
 void RWDModule::intClearToSend()
 {
+  //Start sending command when Clear To Send falls
   if(m_state == CMD_QUEUED)
   {
     m_state = SENDING_CMD;
@@ -66,8 +67,8 @@
 {
   if(m_state != SENDING_CMD)
     return;  
-  m_serial.putc((char)m_cmd);
-//  printf("%02x ",(char)m_cmd);
+  if(m_pos==0) //Must send command-byte first
+    m_serial.putc((char)m_cmd);
   while(true)
   {
     if(m_pos >= m_paramsLen)
@@ -77,14 +78,13 @@
       return;
     }
     m_serial.putc((char)m_paramsBuf[m_pos]);
-//    printf("%02x ",(char)m_paramsBuf[m_pos]);
     m_pos++;
   }
 }
 
 void RWDModule::intRx()
 {
-  if(m_state == WAITING_FOR_ACK)
+  if(m_state == WAITING_FOR_ACK) //Get answer
   {
     m_ack = m_serial.getc();
     if( (m_ack & m_ackOkMask) != m_ackOk )
@@ -102,13 +102,13 @@
       return;
     }
   }
-  if(m_state != RECEIVING_ACK)
+  if(m_state != RECEIVING_ACK) //Error
   {
     while(m_serial.readable())
       m_serial.getc(); //Dump these bytes
     return; 
   }
-  while(m_serial.readable())
+  while(m_serial.readable()) //Read payload
   {
     m_respBuf[m_pos] = (byte) m_serial.getc();
     m_pos++;