Changes between Version 11 and Version 12 of Docs/Prog/Manual/ApplicationLibraries/lib825ev/Weight/StartRepeatMulti


Ignore:
Timestamp:
05/30/14 10:07:58 (11 years ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/ApplicationLibraries/lib825ev/Weight/StartRepeatMulti

    v11 v12  
    9292
    9393        MnBdSetEvent(MNBD_REQ_REP_MULTI, MnBdEventMultiRcv);
     94        // Set the comm event to our MnBdSerialDataRcv function to receive serial port data from COM3 and COM4
    9495        MnBdSetCommEvent(MnBdSerialDataRcv);
    9596
     
    170171} mnbd_serial[2] = { { "", 0 }, { "", 0 } };
    171172
    172 
     173// Called automatically during MnBdRead
    173174int MnBdSerialDataRcv(int nPort, int nLen, unsigned char* data)
    174175{
     
    178179          if(data[n] == '\r')
    179180          {
    180                mnbd_serial[nPort].buffer[mnbd_serial[nPort].pos = '\0';
     181               mnbd_serial[nPort].buffer[mnbd_serial[nPort].pos] = '\0'; // Terminate the string
    181182               printf("rcv com %d [%s]\r\n", nPort + 3, mnbd_serial[nPort].buffer);
    182 
    183            }
    184            else
    185            {
    186                mnbd_serial[nPort].buffer[mnbd_serial[nPort].pos++] = data[n];
    187            }
    188    
     183               mnbd_serial[nPort].pos = 0;
     184          }
     185          else if(mnbd_serial[nPort].pos < 99) // prevent buffer overflow
     186          {
     187              mnbd_serial[nPort].buffer[mnbd_serial[nPort].pos++] = data[n];
     188          }
    189189     }
     190     return 0;
    190191}
    191192}}}