77* Copyright (C) 2015 Anton Viktorov <[email protected] > 88* https://github.com/latonita/can-ascii
99*
10- * This library is free software. You may use/redistribute it under The MIT License terms.
10+ * This library is free software. You may use/redistribute it under The MIT License terms.
1111*
1212*****************************************************************************************/
1313
@@ -124,6 +124,7 @@ void Can232::loopFunc() {
124124 Serial.flush ();
125125 }
126126}
127+
127128void Can232::serialEventFunc () {
128129 while (Serial.available ()) {
129130 char inChar = (char )Serial.read ();
@@ -151,7 +152,7 @@ INT8U Can232::exec() {
151152 case LW232_ERR_NOT_IMPLEMENTED:
152153 // Choose behavior: will it fail or not when not implemented command comes in. Some can monitors might be affected by this selection.
153154 Serial.write (LW232_RET_ASCII_ERROR);
154- // Serial.write(LW232_RET_ASCII_OK);
155+ // Serial.write(LW232_RET_ASCII_OK);
155156 break ;
156157 default :
157158 Serial.write (LW232_RET_ASCII_ERROR);
@@ -169,20 +170,20 @@ INT8U Can232::parseAndRunCommand() {
169170 // __debug_buf("RX:", (char*)lw232Message, strlen((char*)lw232Message));
170171
171172 switch (lw232Message[0 ]) {
172- case LW232_CMD_SETUP:
173+ case LW232_CMD_SETUP:
173174 // Sn[CR] Setup with standard CAN bit-rates where n is 0-9.
174175 if (lw232CanChannelMode == LW232_STATUS_CAN_CLOSED) {
175176 idx = HexHelper::parseNibbleWithLimit (lw232Message[1 ], LW232_CAN_BAUD_NUM);
176- lw232CanSpeedSelection = lw232CanBaudRates[idx];
177+ lw232CanSpeedSelection = lw232CanBaudRates[idx];
177178 }
178179 else {
179180 ret = LW232_ERR;
180181 }
181182 break ;
182- case LW232_CMD_SETUP_BTR:
183+ case LW232_CMD_SETUP_BTR:
183184 // sxxyy[CR] Setup with BTR0/BTR1 CAN bit-rates where xx and yy is a hex value.
184185 ret = LW232_ERR; break ;
185- case LW232_CMD_OPEN:
186+ case LW232_CMD_OPEN:
186187 // O[CR] Open the CAN channel in normal mode (sending & receiving).
187188 if (lw232CanChannelMode == LW232_STATUS_CAN_CLOSED) {
188189 ret = openCanBus ();
@@ -194,7 +195,7 @@ INT8U Can232::parseAndRunCommand() {
194195 ret = LW232_ERR;
195196 }
196197 break ;
197- case LW232_CMD_LISTEN:
198+ case LW232_CMD_LISTEN:
198199 // L[CR] Open the CAN channel in listen only mode (receiving).
199200 if (lw232CanChannelMode == LW232_STATUS_CAN_CLOSED) {
200201 ret = openCanBus ();
@@ -206,7 +207,7 @@ INT8U Can232::parseAndRunCommand() {
206207 ret = LW232_ERR;
207208 }
208209 break ;
209- case LW232_CMD_CLOSE:
210+ case LW232_CMD_CLOSE:
210211 // C[CR] Close the CAN channel.
211212 if (lw232CanChannelMode != LW232_STATUS_CAN_CLOSED) {
212213 lw232CanChannelMode = LW232_STATUS_CAN_CLOSED;
@@ -228,7 +229,7 @@ INT8U Can232::parseAndRunCommand() {
228229 ret = LW232_ERR;
229230 } else if (lw232AutoPoll) {
230231 ret = LW232_OK_SMALL;
231- }
232+ }
232233 }
233234 else {
234235 ret = LW232_ERR;
@@ -412,8 +413,6 @@ INT8U Can232::readMsgBufID(INT32U *ID, INT8U *len, INT8U buf[]) {
412413#endif
413414}
414415
415-
416-
417416INT8U Can232::receiveSingleFrame () {
418417 INT8U ret = LW232_OK;
419418 INT8U idx = 0 ;
@@ -445,7 +444,7 @@ INT8U Can232::receiveSingleFrame() {
445444 INT32U time = millis ();
446445 if (lw232TimeStamp == LW232_TIMESTAMP_ON_NORMAL) {
447446 // standard LAWICEL protocol. two bytes.
448- time %= 60000 ;
447+ time %= 60000 ;
449448 } else {
450449 // non standard protocol - 4 bytes timestamp
451450 HexHelper::printFullByte (HIGH_BYTE (HIGH_WORD (time)));
@@ -473,7 +472,7 @@ INT8U Can232::isExtendedFrame() {
473472
474473
475474INT8U Can232::checkPassFilter (INT32U addr) {
476- if (userAddressFilterFunc == 0 )
475+ if (userAddressFilterFunc == 0 )
477476 return LW232_FILTER_PROCESS;
478477
479478 return (*userAddressFilterFunc)(addr);
0 commit comments