// AnoKeyFrm.psf file // OnStart Event creates two STD CAN frames. The OnKey event // for 'A' will increase the speed if the speed is less than // 90 and increase the rpm is the rpm is less than or equal // to 20 and then transmit the DataFrames. The OnKey event // for 'B' will decrease the speed if the speed is greater // than or equal to 17 and decrease the rpm is the rpm is // greater than or equal to 4, and then transmit a DataFrame. DataFrame *sendFrm1; DataFrame *sendFrm2; char speed; char rpm; int flag1,flag2; [GFuncs] NumFuncs= 0 FuncNames= [FuncCode] [EventCode] [OnError] FuncBody=void OnError(uchar channel, uchar error_type) { } [OnFrame] FuncBody=void OnFrame(DataFrame *frame, uchar channel) { } [OnKey] FuncBody=void OnKey(char character) { int result; char buff[30]; if( character == 'A') { if(speed<90) { speed = speed + 17; sprintf(buff, "Speed %d", speed); WriteInfo(buff); } if(rpm<=20) { rpm = rpm + 4; sprintf(buff, "RPM %d", rpm); WriteInfo(buff); } } if( character == 'B') { if(speed>=17) { speed = speed -17; sprintf(buff, "Speed %d", speed); WriteInfo(buff); } if(rpm>=4) { rpm = rpm - 4; sprintf(buff, "RPM %d", rpm); WriteInfo(buff); } } DATA(sendFrm1)[6]=speed; DATA(sendFrm2)[4]=rpm; result = 0; result = TransmitDataFrame(sendFrm1, 1); if (result == -1) WriteInfo("Transmit Failed"); result = 0; result = TransmitDataFrame(sendFrm2, 1); if (result == -1) WriteInfo("Transmit Failed"); } [OnStart] FuncBody=void OnStart(long time) { int i ; flag1 = 0; flag2 = 0; speed = 0; rpm = 0; WriteInfo("I am in"); sendFrm1 = CreateDataFrame(11,8, 0); sendFrm2 = CreateDataFrame(11,8, 0); if (sendFrm1 == NULL) { WriteInfo("Unable to initialize frame 1"); return; } if (sendFrm2 == NULL) { WriteInfo("Unable to initialize frame 2"); return; } sendFrm1->datalen = 8; sendFrm1->Idlen = 11; sendFrm1->extralen = 0; sendFrm2->datalen = 8; sendFrm2->Idlen = 11; sendFrm2->extralen = 0; ID(sendFrm1)[0] = 0x04; ID(sendFrm1)[1] = 0xB0; ID(sendFrm2)[0] = 0x01; ID(sendFrm2)[1] = 0x2C; for (i = 0; i< 8; i++) { DATA(sendFrm1)[i]=0x00; DATA(sendFrm2)[i]=0x00; } } [OnStop] FuncBody=void OnStop(long time) { } [OnTimer] FuncBody=void OnTimer(uint timerid) { } [OnTrigger] FuncBody=void OnTrigger(long time) { } [OnSerial] FuncBody=void OnSerial(const void * data, unsigned short datacount) { } [OnMsg] FuncBody=void OnMsg(char * string) { } [EndPSF]