void processInput(void)
{
char tempstr[16];
int j;
unsigned char CRC;
tempstr[0]=0; // clear for later use
CRC=comInput1[0]+3;
if(comInputLoc1>=CRC) // comInputLoc1 = input from com1, how many bytes are in the buffer
{
for(j=0;j<=CRC;j++)
{
tempstr[j]=comInput1[j];
comInput1[j]=comInput1[j+tempstr[0]+3];
}
comInputLoc1=comInputLoc1-(tempstr[0]+3);
comInput1[comInputLoc1+1]=0;
}
if(tempstr[0]!=0) // Validate CRC
{
CRC=0;
for(j=0;j<tempstr[0]+2;j++)
{
CRC=CRC+tempstr[j];
}
CRC=0xff-CRC;
CRC=CRC+1;
if(CRC!=tempstr[j]) tempstr[0]=0; // Clear it out, it failed
}
if(tempstr[0]!=0) // process the commands coming in
{
switch(tempstr[2])
{
case 0x00:
break;
case 0x01: // Send alternator Voltage
CRC=0;
tempstr[0]=3;
j=altVoltOutConv; // fill in with real data later
j=j >> 8; // strip lower bytes
tempstr[3]=j;
j=altVoltOutConv; // fill in with real data later
j=(char)j;
tempstr[4]=j;
CRC=tempstr[0]+tempstr[1]+tempstr[2]+tempstr[3]+tempstr[4];
CRC=0xff-CRC;
CRC++;
tempstr[5]=CRC;
break;
default:
break;
}
}
}