Revision: 1322 Author: bvwelch Date: Mon Sep 14 18:56:49 2009 Log: support standard and extended CAN frames
http://code.google.com/p/jallib/source/detail?r=1322 Modified: /trunk/sample/18f2585_can_monitor.jal ======================================= --- /trunk/sample/18f2585_can_monitor.jal Thu Aug 27 14:16:33 2009 +++ /trunk/sample/18f2585_can_monitor.jal Mon Sep 14 18:56:49 2009 @@ -51,10 +51,13 @@ can_reset() can_set_config(3, 0x9E, 3) -- 125K bps CIOCON = 0x20 -- TXCAN, high when recessive -RXB0CON = 0x24 -- standard identifier, rollover/ double-buffer -RXB1CON = 0x20 -- standard identifier -can_set_rxb0_mask(0,0,0,0) -- match all msgs -can_set_rxb1_mask(0,0,0,0) -- match all msgs + +RXB0CON = 0x40 -- for this example, we route all extended frames to buffer #0. +RXB1CON = 0x00 -- standard frames go to buffer #1. + +can_set_rxb0_mask(0,0,0,0) +can_set_rxb1_mask(0,0,0,0) + TXB0CON = 0; TXB1CON = 0; TXB2CON = 0; @@ -84,13 +87,12 @@ var bit got_msg var byte a,b,c,d, i, len var byte rxdata[8] - var word std_id + var dword can_id a = CANSTAT b = COMSTAT c = RXB0CON d = RXB1CON - got_msg = can_receive(1, std_id, rxdata, len) -- wiggle the top-left corner lcd_home() @@ -111,10 +113,20 @@ print_byte_hex(lcd, d) lcd = " " - -- now the data buffer - if got_msg != 0 then - lcd_cursor_position(2,0) - print_word_hex(lcd, std_id) + -- check for a message + if led != 0 then + got_msg = can_receive(0, can_id, rxdata, len) + else + got_msg = can_receive(1, can_id, rxdata, len) + end if + + if got_msg then + if can_is_std_id(can_id) then + lcd_cursor_position(2,0) + else + lcd_cursor_position(3,0) + end if + print_dword_hex(lcd, can_id) lcd = " " for 8 using i loop var byte v --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
