// hbcccanbridge // Take A CAN Message from one channel and change it to an SCP message // and send out on the SCP channel DataFrame * HBCCFrm; /* SCP Frame */ DataFrame * eCANFrm; /* Ext CAN Frame */ DataFrame * sCANFrm; /* Std CAN Frame */ void OnError(uchar channel, uchar error_type) { } void OnFrame(DataFrame *frame, uchar channel) { /* gryphon channels are numbered sequentially */ /* for example if you have a dw-can card in slot 1 */ /* and a hbcc card in slot 2 */ /* the channel numbers would occurs as listed */ /* below: */ /* */ /* channel 1 - dw can chnl1 */ /* channel 2 - dw can chnl2 */ /* channel 3 - hbcc card */ switch(channel) { case 1: /* Process CAN frames from channel 1*/ if(frame->Idlen==29) /* process extended can frames */ { /* These if statements are ugly but I did it this way because I am unsure of byte widths under linux and did not want to try bit shifting the individual bytes into a long */ if(ID(frame)[0] == 0x01 && ID(frame)[1] == 0xBB && ID(frame)[2] == 0xCC && ID(frame)[3] ==0xDD) { /* Process CAN identifier 0x01BBCCDD */ /* to transmit an HBCC frame with a header of 0x04CCDD and data of */ /* 0x00 0x11 0x22 */ HBCCFrm->datalen = 3; ID(HBCCFrm)[0] = 0x04; ID(HBCCFrm)[1] = 0xCC; ID(HBCCFrm)[2] = 0xDD; DATA(HBCCFrm)[0] = 0x00; DATA(HBCCFrm)[1] = 0x11; DATA(HBCCFrm)[2] = 0x22; TransmitDataFrame(HBCCFrm,3); } else if(ID(frame)[0] == 0x1F && ID(frame)[1] == 0xFF && ID(frame)[2] == 0xFF && ID(frame)[3] ==0xFF) { /* Process CAN identifier 0x1FFFFFFF */ /* to transmit an HBCC frame with a header of 0x043344 and data of */ /* 0x33 0x22 0x11 0x00*/ HBCCFrm->datalen = 4; ID(HBCCFrm)[0] = 0x04; ID(HBCCFrm)[1] = 0x33; ID(HBCCFrm)[2] = 0x44; DATA(HBCCFrm)[0] = 0x33; DATA(HBCCFrm)[1] = 0x22; DATA(HBCCFrm)[2] = 0x11; DATA(HBCCFrm)[3] = 0x00; TransmitDataFrame(HBCCFrm,3); } } else if(frame->Idlen==11) /* process standard can frames */ { /* take care of can frames here */ } else { /* something's wrong! */ } break; case 2: /* Process CAN frames from channel 2 */ break; case 3: /* Process HBCC(SCP frames from channel 3 */ break; } } void OnKey(char character) { } void OnStart(long time) { /* Make frames large enough to handle protocol note that the Idlen is in bits not bytes! */ HBCCFrm = CreateDataFrame(24,7,0); sCANFrm = CreateDataFrame(11,8,0); eCANFrm = CreateDataFrame(29,8,0); } void OnStop(long time) { FreeDataFrame(HBCCFrm); FreeDataFrame(sCANFrm); FreeDataFrame(eCANFrm); } void OnTimer(uint timerid) { } void OnTrigger(long time) { } void OnSerial(const void * data, unsigned short datacount) { } void OnMsg(char * string) { }