* detect auto baud rate on can bus in linux driver. @ 2014-04-24 13:20 Ratheendran 2014-04-27 9:44 ` John Whitmore 0 siblings, 1 reply; 14+ messages in thread From: Ratheendran @ 2014-04-24 13:20 UTC (permalink / raw) To: linux-can Hi All, Need you help in understanding detecting auto baud rate of CAN bus. please share your valuable experience. I am using imx6 processor which has flexcan hardware driver implemented as socketcan stack. With Regards, Ratheendran ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-24 13:20 detect auto baud rate on can bus in linux driver Ratheendran @ 2014-04-27 9:44 ` John Whitmore 2014-04-27 18:01 ` Kurt Van Dijck 0 siblings, 1 reply; 14+ messages in thread From: John Whitmore @ 2014-04-27 9:44 UTC (permalink / raw) To: Ratheendran; +Cc: linux-can On Thu, Apr 24, 2014 at 06:50:54PM +0530, Ratheendran wrote: > Hi All, > > Need you help in understanding detecting auto baud rate of CAN bus. > please share your valuable experience. > > I am using imx6 processor which has flexcan hardware driver > implemented as socketcan stack. > I've used auto baud rate detection with the Microchip MCP2515 CAN Controller connected to a PIC controller, but not with Linux, as yet. I'm working on my own CAN Bus network so have control of all the nodes. There is a "Ping" Protocol built into the nodes so that if there is no network traffic in a certain period of time a random node will fire a "Ping" frame onto the CAN Bus. That way I'm guaranteed that there will be network traffic to listen to. In addition to network traffic my network uses a fixed number of baud rates: 10K, 20K, 50K, 125K, 250K, 500, 800K, and 1M Now given all that on the network I simply set the MCP2515 into listen only mode at a baud rate of 10K. If the Ping message is set for 10 seconds and I listen for 30 Seconds I should at least get 3 CAN Frames. If I've got the wrong baud rate I'll get MERRE errors in listen mode. My driver simply, when in listen mode, counts received good frames and errors. If after 30 seconds I've got good frames and no errors then I've found the baud rate being used by the network and I can drop out of listen mode. If there are any errors then simply move up to the next baud rate and start listening again. This all works for me as I'm assured of traffic and have a limited number of baud rates to search through. I keep meaning to look at this on Linux but I've been distracted with other work. I'll get back to it. Not sure how it would fit into the Linux can architecture. The Driver code would have to count errors and userspace would have to look at the results and change baud rate, or connect. Hope that's of some help. > With Regards, > Ratheendran > -- > To unsubscribe from this list: send the line "unsubscribe linux-can" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-27 9:44 ` John Whitmore @ 2014-04-27 18:01 ` Kurt Van Dijck 2014-04-29 8:33 ` Ratheendran S. Rajeshwaran ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Kurt Van Dijck @ 2014-04-27 18:01 UTC (permalink / raw) To: Ratheendran; +Cc: John Whitmore, linux-can Hey, On Sun, Apr 27, 2014 at 10:44:22AM +0100, John Whitmore wrote: > On Thu, Apr 24, 2014 at 06:50:54PM +0530, Ratheendran wrote: > > Hi All, > > > > Need you help in understanding detecting auto baud rate of CAN bus. > > please share your valuable experience. The baudrate detection principle is: configure your CAN chip, and if you receive something, then the baudrate was good. This can only work when there is traffic. The CAN chip should be set in a mode that does not disturb the bus. This mode is called 'listen-only' for CAN. Be sure to read http://www.can-cia.org/fileadmin/cia/files/icc/9/koppe.pdf I did only read it quickly, and it appears most items have been explained a bit. John Whitmore explained his scenario very well. I just want to add some comments with special regard to linux. > > > > I am using imx6 processor which has flexcan hardware driver > > implemented as socketcan stack. > > Theoretically/ideally, all linux-can drivers behave the same. Practically, a required feature for baudrate detection on CAN is the listen-only mode. linux-can provides the API, but not all drivers/devices support it. Look into the code for CAN_CTRLMODE_LISTENONLY. My 3.12 tree flexcan driver seems to support it, but I clearly did not test with real hardware. > > I've used auto baud rate detection with the Microchip MCP2515 CAN Controller > connected to a PIC controller, but not with Linux, as yet. > I'm working on my > own CAN Bus network so have control of all the nodes. There is a "Ping" > Protocol built into the nodes so that if there is no network traffic in a > certain period of time a random node will fire a "Ping" frame onto the CAN > Bus. That way I'm guaranteed that there will be network traffic to listen to. > > In addition to network traffic my network uses a fixed number of baud rates: > > 10K, 20K, 50K, 125K, 250K, 500, 800K, and 1M > > Now given all that on the network I simply set the MCP2515 into listen only > mode at a baud rate of 10K. If the Ping message is set for 10 seconds and I > listen for 30 Seconds I should at least get 3 CAN Frames. If I've got the > wrong baud rate I'll get MERRE errors in listen mode. My driver simply, when > in listen mode, counts received good frames and errors. If after 30 seconds > I've got good frames and no errors then I've found the baud rate being used by > the network and I can drop out of listen mode. If there are any errors then > simply move up to the next baud rate and start listening again. > > This all works for me as I'm assured of traffic and have a limited number of > baud rates to search through. > > I keep meaning to look at this on Linux but I've been distracted with other > work. I'll get back to it. Not sure how it would fit into the Linux can > architecture. Autobaud is, IMO, a userspace thing. The principle has been explained, and with iproute2 & candump piping into grep or wc, you could even make a shell script for that. > The Driver code would have to count errors and userspace would > have to look at the results and change baud rate, or connect. > > Hope that's of some help. > > > With Regards, > > Ratheendran Kurt ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: detect auto baud rate on can bus in linux driver. 2014-04-27 18:01 ` Kurt Van Dijck @ 2014-04-29 8:33 ` Ratheendran S. Rajeshwaran 2014-04-29 8:35 ` Ratheendran S. Rajeshwaran 2014-04-29 19:58 ` Robert Schwebel 2014-04-29 12:47 ` Heinz-Jürgen Oertel [not found] ` <535F5449.7000108@tataelxsi.co.in> 2 siblings, 2 replies; 14+ messages in thread From: Ratheendran S. Rajeshwaran @ 2014-04-29 8:33 UTC (permalink / raw) To: Kurt Van Dijck; +Cc: John Whitmore, linux-can@vger.kernel.org Thanks John , Kurt for your valuable support. I am going ahead with the shell script & iproute2 supported tool testing a set of fixed baud rate from table. My observations with the existing imx6 flexcan hardware running linux 3.0.x. Two imx6 board ,both are enabled for FLEXCAN communication. CAN dev bring up command with baud rate. command -> ip link set can0 up type can bitrate 125000 one board run cansend while other end candump--e command Case 1 both imx6 operate on same CAN baudrate cansend can0 -i0x100 11 22 33 44 on candump terminal I receive <0x100> [4] 0b 16 21 2c I do ip -details -statistics link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10 link/can can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 bitrate 250000 sample-point 0.866 tq 266 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 5 0 0 RX: bytes packets errors dropped overrun mcast 40 5 0 0 0 0 TX: bytes packets errors dropped carrier collsns 32 8 0 2 0 0 Case 2: imx6 CAN on different baud rate. received packets( I am not able to interpret the below packet) <0x004> [8] 00 04 00 00 00 00 00 00 ip -details -statistics link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10 link/can can state ERROR-WARNING (berr-counter tx 0 rx 128) restart-ms 0 bitrate 250000 sample-point 0.866 tq 266 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 14 1 0 RX: bytes packets errors dropped overrun mcast 144 22 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 I am wondering a shell script setting the different baud rate and then checking the can status to decide the correct baud rate. our custom application need two can bus,one raw and other j1939.in case of j1939 I will use iproute2-j1939 and can-utility for j1939. is there any better approach to do it,I am open for better Ideas. Regards, Ratheendran ________________________________________ From: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> Sent: 27 April 2014 23:31 To: Ratheendran S. Rajeshwaran Cc: John Whitmore; linux-can@vger.kernel.org Subject: Re: detect auto baud rate on can bus in linux driver. Hey, On Sun, Apr 27, 2014 at 10:44:22AM +0100, John Whitmore wrote: > On Thu, Apr 24, 2014 at 06:50:54PM +0530, Ratheendran wrote: > > Hi All, > > > > Need you help in understanding detecting auto baud rate of CAN bus. > > please share your valuable experience. The baudrate detection principle is: configure your CAN chip, and if you receive something, then the baudrate was good. This can only work when there is traffic. The CAN chip should be set in a mode that does not disturb the bus. This mode is called 'listen-only' for CAN. Be sure to read http://www.can-cia.org/fileadmin/cia/files/icc/9/koppe.pdf I did only read it quickly, and it appears most items have been explained a bit. John Whitmore explained his scenario very well. I just want to add some comments with special regard to linux. > > > > I am using imx6 processor which has flexcan hardware driver > > implemented as socketcan stack. > > Theoretically/ideally, all linux-can drivers behave the same. Practically, a required feature for baudrate detection on CAN is the listen-only mode. linux-can provides the API, but not all drivers/devices support it. Look into the code for CAN_CTRLMODE_LISTENONLY. My 3.12 tree flexcan driver seems to support it, but I clearly did not test with real hardware. > > I've used auto baud rate detection with the Microchip MCP2515 CAN Controller > connected to a PIC controller, but not with Linux, as yet. > I'm working on my > own CAN Bus network so have control of all the nodes. There is a "Ping" > Protocol built into the nodes so that if there is no network traffic in a > certain period of time a random node will fire a "Ping" frame onto the CAN > Bus. That way I'm guaranteed that there will be network traffic to listen to. > > In addition to network traffic my network uses a fixed number of baud rates: > > 10K, 20K, 50K, 125K, 250K, 500, 800K, and 1M > > Now given all that on the network I simply set the MCP2515 into listen only > mode at a baud rate of 10K. If the Ping message is set for 10 seconds and I > listen for 30 Seconds I should at least get 3 CAN Frames. If I've got the > wrong baud rate I'll get MERRE errors in listen mode. My driver simply, when > in listen mode, counts received good frames and errors. If after 30 seconds > I've got good frames and no errors then I've found the baud rate being used by > the network and I can drop out of listen mode. If there are any errors then > simply move up to the next baud rate and start listening again. > > This all works for me as I'm assured of traffic and have a limited number of > baud rates to search through. > > I keep meaning to look at this on Linux but I've been distracted with other > work. I'll get back to it. Not sure how it would fit into the Linux can > architecture. Autobaud is, IMO, a userspace thing. The principle has been explained, and with iproute2 & candump piping into grep or wc, you could even make a shell script for that. > The Driver code would have to count errors and userspace would > have to look at the results and change baud rate, or connect. > > Hope that's of some help. > > > With Regards, > > Ratheendran Kurt ^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: detect auto baud rate on can bus in linux driver. 2014-04-29 8:33 ` Ratheendran S. Rajeshwaran @ 2014-04-29 8:35 ` Ratheendran S. Rajeshwaran 2014-04-29 19:58 ` Robert Schwebel 1 sibling, 0 replies; 14+ messages in thread From: Ratheendran S. Rajeshwaran @ 2014-04-29 8:35 UTC (permalink / raw) To: Kurt Van Dijck; +Cc: linux-can@vger.kernel.org Thanks John , Kurt for your valuable support. I am going ahead with the shell script & iproute2 supported tool testing a set of fixed baud rate from table. My observations with the existing imx6 flexcan hardware running linux 3.0.x. Two imx6 board ,both are enabled for FLEXCAN communication. CAN dev bring up command with baud rate. command -> ip link set can0 up type can bitrate 125000 one board run cansend while other end candump--e command Case 1 both imx6 operate on same CAN baudrate cansend can0 -i0x100 11 22 33 44 on candump terminal I receive <0x100> [4] 0b 16 21 2c I do ip -details -statistics link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10 link/can can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 bitrate 250000 sample-point 0.866 tq 266 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 5 0 0 RX: bytes packets errors dropped overrun mcast 40 5 0 0 0 0 TX: bytes packets errors dropped carrier collsns 32 8 0 2 0 0 Case 2: imx6 CAN on different baud rate. received packets( I am not able to interpret the below packet) <0x004> [8] 00 04 00 00 00 00 00 00 ip -details -statistics link show can0 2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10 link/can can state ERROR-WARNING (berr-counter tx 0 rx 128) restart-ms 0 bitrate 250000 sample-point 0.866 tq 266 prop-seg 6 phase-seg1 6 phase-seg2 2 sjw 1 flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1 clock 30000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 14 1 0 RX: bytes packets errors dropped overrun mcast 144 22 0 0 0 0 TX: bytes packets errors dropped carrier collsns 0 0 0 0 0 0 I am wondering a shell script setting the different baud rate and then checking the can status to decide the correct baud rate. our custom application need two can bus,one raw and other j1939.in case of j1939 I will use iproute2-j1939 and can-utility for j1939. is there any better approach to do it,I am open for better Ideas. Regards, Ratheendran ________________________________________ From: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> Sent: 27 April 2014 23:31 To: Ratheendran S. Rajeshwaran Cc: John Whitmore; linux-can@vger.kernel.org Subject: Re: detect auto baud rate on can bus in linux driver. Hey, On Sun, Apr 27, 2014 at 10:44:22AM +0100, John Whitmore wrote: > On Thu, Apr 24, 2014 at 06:50:54PM +0530, Ratheendran wrote: > > Hi All, > > > > Need you help in understanding detecting auto baud rate of CAN bus. > > please share your valuable experience. The baudrate detection principle is: configure your CAN chip, and if you receive something, then the baudrate was good. This can only work when there is traffic. The CAN chip should be set in a mode that does not disturb the bus. This mode is called 'listen-only' for CAN. Be sure to read http://www.can-cia.org/fileadmin/cia/files/icc/9/koppe.pdf I did only read it quickly, and it appears most items have been explained a bit. John Whitmore explained his scenario very well. I just want to add some comments with special regard to linux. > > > > I am using imx6 processor which has flexcan hardware driver > > implemented as socketcan stack. > > Theoretically/ideally, all linux-can drivers behave the same. Practically, a required feature for baudrate detection on CAN is the listen-only mode. linux-can provides the API, but not all drivers/devices support it. Look into the code for CAN_CTRLMODE_LISTENONLY. My 3.12 tree flexcan driver seems to support it, but I clearly did not test with real hardware. > > I've used auto baud rate detection with the Microchip MCP2515 CAN Controller > connected to a PIC controller, but not with Linux, as yet. > I'm working on my > own CAN Bus network so have control of all the nodes. There is a "Ping" > Protocol built into the nodes so that if there is no network traffic in a > certain period of time a random node will fire a "Ping" frame onto the CAN > Bus. That way I'm guaranteed that there will be network traffic to listen to. > > In addition to network traffic my network uses a fixed number of baud rates: > > 10K, 20K, 50K, 125K, 250K, 500, 800K, and 1M > > Now given all that on the network I simply set the MCP2515 into listen only > mode at a baud rate of 10K. If the Ping message is set for 10 seconds and I > listen for 30 Seconds I should at least get 3 CAN Frames. If I've got the > wrong baud rate I'll get MERRE errors in listen mode. My driver simply, when > in listen mode, counts received good frames and errors. If after 30 seconds > I've got good frames and no errors then I've found the baud rate being used by > the network and I can drop out of listen mode. If there are any errors then > simply move up to the next baud rate and start listening again. > > This all works for me as I'm assured of traffic and have a limited number of > baud rates to search through. > > I keep meaning to look at this on Linux but I've been distracted with other > work. I'll get back to it. Not sure how it would fit into the Linux can > architecture. Autobaud is, IMO, a userspace thing. The principle has been explained, and with iproute2 & candump piping into grep or wc, you could even make a shell script for that. > The Driver code would have to count errors and userspace would > have to look at the results and change baud rate, or connect. > > Hope that's of some help. > > > With Regards, > > Ratheendran Kurt ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-29 8:33 ` Ratheendran S. Rajeshwaran 2014-04-29 8:35 ` Ratheendran S. Rajeshwaran @ 2014-04-29 19:58 ` Robert Schwebel [not found] ` <5360E8A6.8040204@tataelxsi.co.in> 1 sibling, 1 reply; 14+ messages in thread From: Robert Schwebel @ 2014-04-29 19:58 UTC (permalink / raw) To: Ratheendran S. Rajeshwaran Cc: Kurt Van Dijck, John Whitmore, linux-can@vger.kernel.org On Tue, Apr 29, 2014 at 08:33:59AM +0000, Ratheendran S. Rajeshwaran wrote: > My observations with the existing imx6 flexcan hardware running linux 3.0.x. Could you retry with 3.14? There has been a lot of activity recently. rsc -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <5360E8A6.8040204@tataelxsi.co.in>]
* Re: detect auto baud rate on can bus in linux driver. [not found] ` <5360E8A6.8040204@tataelxsi.co.in> @ 2014-04-30 14:41 ` Kurt Van Dijck 2014-04-30 16:35 ` Oliver Hartkopp 0 siblings, 1 reply; 14+ messages in thread From: Kurt Van Dijck @ 2014-04-30 14:41 UTC (permalink / raw) To: Ratheendran; +Cc: Robert Schwebel, John Whitmore, linux-can@vger.kernel.org Hey, On Wed, Apr 30, 2014 at 05:42:22PM +0530, Ratheendran wrote: > Thanks again, I Appreciate your support, this has helped my understanding > ,build confidence on socketcan. [...] > Hi kurt, > > I am not able to set the timeout scenario for candump command, do i need to > send a killall signal to candump after a wait period. > I believe this approach is a good one, but the timeout thing is the tricky part. I'll take a look next few days. Kurt > > > With regards, > Ratheendran > > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-30 14:41 ` Kurt Van Dijck @ 2014-04-30 16:35 ` Oliver Hartkopp 2014-05-01 18:49 ` Kurt Van Dijck 0 siblings, 1 reply; 14+ messages in thread From: Oliver Hartkopp @ 2014-04-30 16:35 UTC (permalink / raw) To: Ratheendran, Robert Schwebel, John Whitmore, Kurt Van Dijck Cc: linux-can@vger.kernel.org On 30.04.2014 16:41, Kurt Van Dijck wrote: > Hey, > > On Wed, Apr 30, 2014 at 05:42:22PM +0530, Ratheendran wrote: >> Thanks again, I Appreciate your support, this has helped my understanding >> ,build confidence on socketcan. > [...] >> Hi kurt, >> >> I am not able to set the timeout scenario for candump command, do i need to >> send a killall signal to candump after a wait period. >> > > I believe this approach is a good one, but the timeout thing is the tricky part. > I'll take a look next few days. > There is already an option '-T <msecs>' for this in the latest candump on the latest gitorious can-utils git: Usage: candump [options] <CAN interface>+ (use CTRL-C to terminate candump) Options: -t <type> (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date) -c (increment color mode level) -i (binary output - may exceed 80 chars/line) -a (enable additional ASCII output) -S (swap byte order in printed CAN data[] - marked with '`' ) -s <level> (silent mode - 0: off (default) 1: animation 2: silent) -b <can> (bridge mode - send received frames to <can>) -B <can> (bridge mode - like '-b' with disabled loopback) -u <usecs> (delay bridge forwarding by <usecs> microseconds) -l (log CAN-frames into file. Sets '-s 2' by default) -L (use log file format on stdout) -n <count> (terminate after receiption of <count> CAN frames) -r <size> (set socket receive buffer to <size>) -d (monitor dropped CAN frames) -e (dump CAN error frames in human-readable format) -x (print extra message infos, rx/tx brs esi) -T <msecs> (terminate after <msecs> without any reception) So candump -T 1000 -n 4 can0 | wc -l would produce values from 1 to 4 when there was some traffic within one second of reception or zero when not traffic was detected. if [ `candump -T 1000 -n 4 can0 | wc -l` -ne 0 ]; then echo "traffic"; else echo "nothing"; fi So updating your can-utils helps :-) Regards, Oliver ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-30 16:35 ` Oliver Hartkopp @ 2014-05-01 18:49 ` Kurt Van Dijck [not found] ` <5363243E.7070406@tataelxsi.co.in> 0 siblings, 1 reply; 14+ messages in thread From: Kurt Van Dijck @ 2014-05-01 18:49 UTC (permalink / raw) To: Ratheendran, Oliver Hartkopp Cc: Robert Schwebel, John Whitmore, linux-can@vger.kernel.org Hey Oliver, On Wed, Apr 30, 2014 at 06:35:12PM +0200, Oliver Hartkopp wrote: > On 30.04.2014 16:41, Kurt Van Dijck wrote: > > Hey, > > > > On Wed, Apr 30, 2014 at 05:42:22PM +0530, Ratheendran wrote: [...] > So > > candump -T 1000 -n 4 can0 | wc -l > > would produce values from 1 to 4 when there was some traffic within one > second of reception or zero when not traffic was detected. > > if [ `candump -T 1000 -n 4 can0 | wc -l` -ne 0 ]; then > > echo "traffic"; > else > echo "nothing"; > fi 4 means here then "return success after 4 frames, and don't keep waiting 1sec"? This 'if' line is the right one to use! Thanks, Kurt ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <5363243E.7070406@tataelxsi.co.in>]
* Re: detect auto baud rate on can bus in linux driver. [not found] ` <5363243E.7070406@tataelxsi.co.in> @ 2014-05-02 11:00 ` Kurt Van Dijck 0 siblings, 0 replies; 14+ messages in thread From: Kurt Van Dijck @ 2014-05-02 11:00 UTC (permalink / raw) To: Ratheendran; +Cc: linux-can@vger.kernel.org, Oliver Hartkopp Hey, On Fri, May 02, 2014 at 10:21:10AM +0530, Ratheendran wrote: > Hey Kurt, > > I just looked into linux-can/can-j1939-utils which I am plan to use on my final > target, for this source candump -T < > option is missing. That is very likely, as the can-j1939-utils forked some time ago, and the -T option is recent. You could merge both using git, or, since can-j1939-utils does not really touch candump, you could just copy the newer candump.c into your can-j1399-utils directory, overwriting the old candump.c. Kind regards, Kurt ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-27 18:01 ` Kurt Van Dijck 2014-04-29 8:33 ` Ratheendran S. Rajeshwaran @ 2014-04-29 12:47 ` Heinz-Jürgen Oertel [not found] ` <535FA7BB.3070700@tataelxsi.co.in> [not found] ` <535F5449.7000108@tataelxsi.co.in> 2 siblings, 1 reply; 14+ messages in thread From: Heinz-Jürgen Oertel @ 2014-04-29 12:47 UTC (permalink / raw) To: Kurt Van Dijck; +Cc: Ratheendran, John Whitmore, linux-can [-- Attachment #1: Type: text/plain, Size: 1703 bytes --] Am Sonntag, 27. April 2014, 20:01:35 schrieb Kurt Van Dijck: > > Autobaud is, IMO, a userspace thing. > The principle has been explained, and with iproute2 & candump piping into > grep or wc, you could even make a shell script for that. In can4linux it can be done in user space, like int do_autobaud(can_fd) { int bitrate[] = {10, 20, 50, 125, 250, 500, 800, 1000 , 0}; int i; int ret; can_statuspar_t status; printf("\tswitch into listen only mode\n"); set_lomode(can_fd, 1); /* for all possible bit rates */ for (i = 0; ; i++) { if (bitrate[i] == 0) { ret = 0; break; } printf("\tTry %d Kbit/s\n", bitrate[i]); set_bitrate(can_fd, bitrate[i]); /* wait one second */ sleep(1); ioctl(can_fd, CAN_IOCTL_STATUS, &status); /* printf("Rx buffer: %d\n", status.rx_buffer_used); */ if (status.rx_buffer_used > 1) { printf("\t\tCould receive frames. Switch back to active mode\n"); ret = bitrate[i]; break; } } if (ret > 0) { /* bit rate detected */ set_lomode(can_fd, 0); } return ret; } Of course the CAN controller should have a 'listen only' mode. On a running EnergyBus it looks like: using CAN device /dev/can1 doing auto bit rate detection now take care that traffic is on the bus switch into listen only mode Try 10 Kbit/s Try 20 Kbit/s Try 50 Kbit/s Try 125 Kbit/s Try 250 Kbit/s Could receive frames. Switch back to active mode -- Mit freundlichen Grüßen Heinz-Jürgen Oertel ------------------------------------------------------------------------- emtas - your embedded solution partner [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <535FA7BB.3070700@tataelxsi.co.in>]
* Re: detect auto baud rate on can bus in linux driver. [not found] ` <535FA7BB.3070700@tataelxsi.co.in> @ 2014-04-29 14:12 ` Heinz-Jürgen Oertel 0 siblings, 0 replies; 14+ messages in thread From: Heinz-Jürgen Oertel @ 2014-04-29 14:12 UTC (permalink / raw) To: Ratheendran; +Cc: Kurt Van Dijck, linux-can [-- Attachment #1: Type: text/plain, Size: 885 bytes --] Am Dienstag, 29. April 2014, 18:53:07 schrieb Ratheendran: > this mode, transmission is disabled, all error counters are frozen and > the module operates > in a CAN Error Passive mode. Only messages *acknowledged by another CAN > station* will be received. In this case always two nodes already communicating are needed in order for the node doing the auto detection. > If FLEXCAN detects a message that has not been acknowledged, it will > flag a BIT0 error (without changing the REC), as if it was trying to > acknowledge the message." Is this BIT0 somehow exported to user space by SocketCAN to get the information "received valid (+ CRC) message but without seeing an ACK" ? -- Mit freundlichen Grüßen Heinz-Jürgen Oertel ------------------------------------------------------------------------- emtas - your embedded solution partner [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 490 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <535F5449.7000108@tataelxsi.co.in>]
* Re: detect auto baud rate on can bus in linux driver. [not found] ` <535F5449.7000108@tataelxsi.co.in> @ 2014-04-29 13:33 ` Kurt Van Dijck 2014-04-29 14:12 ` Wolfgang Grandegger 0 siblings, 1 reply; 14+ messages in thread From: Kurt Van Dijck @ 2014-04-29 13:33 UTC (permalink / raw) To: Ratheendran; +Cc: linux-can, John Whitmore, Wolfgang Grandegger On Tue, Apr 29, 2014 at 12:57:05PM +0530, Ratheendran wrote: > Thanks John , Kurt Van Dijck for your valuable support. > > I am going ahead with the shell script & iproute2 supported tool testing a set > of fixed baud rate from table. > > My observations with the existing imx6 flexcan hardware running linux 3.0.x. > > Two imx6 board ,both are enabled for FLEXCAN communication. > CAN dev bring up command with baud rate. > command -> ip link set can0 up type can bitrate 125000 > one board run cansend while other end candump--e command The 'autobaud' node must do $ ip link set canX type can listen-only on > > > Case 1 both imx6 operate on same CAN baudrate > cansend can0 -i0x100 11 22 33 44 > on candump terminal I receive <0x100> [4] 0b 16 21 2c Do you use the latest tools from gitorious? The syntax of cansend and the output of candump look different. [...] > Case 2: imx6 CAN on different baud rate. > received packets( I am not able to interpret the below packet) > <0x004> [8] 00 04 00 00 00 00 00 00 Well, this is not ok. I'd expect an error or status frame, but I don't see it in your candump output. I do notice that the received frame has 8 bytes, and only 1 bit set. So, if I suppose that the CAN_ERR_FLAG has been set, I see (with include/linux/can/error.h aside) <0x004> Controller problem, info in data[1] data[1] 04: Reached warning level for RX errors. I'd expect something like that. Wolfgang Grandegger may explain more, as he did author these. Next step is to make a script that does all that, and that makes candump stop after a limited time (few seconds). I would suggest to skip a baudrate if you receive any error frame, so the interpretation may be not necessary. Kurt ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: detect auto baud rate on can bus in linux driver. 2014-04-29 13:33 ` Kurt Van Dijck @ 2014-04-29 14:12 ` Wolfgang Grandegger 0 siblings, 0 replies; 14+ messages in thread From: Wolfgang Grandegger @ 2014-04-29 14:12 UTC (permalink / raw) To: Kurt Van Dijck; +Cc: Ratheendran, linux-can, John Whitmore On Tue, 29 Apr 2014 15:33:55 +0200, Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> wrote: > On Tue, Apr 29, 2014 at 12:57:05PM +0530, Ratheendran wrote: >> Thanks John , Kurt Van Dijck for your valuable support. >> >> I am going ahead with the shell script & iproute2 supported tool testing >> a set >> of fixed baud rate from table. >> >> My observations with the existing imx6 flexcan hardware running linux >> 3.0.x. >> >> Two imx6 board ,both are enabled for FLEXCAN communication. >> CAN dev bring up command with baud rate. >> command -> ip link set can0 up type can bitrate 125000 For bus error reporting the option "berr-reporting on" needs to be added. Otherwise only CAN error state changes will be send. >> one board run cansend while other end candump--e command It's good practice to use: # candump -td -e any,0:0,#FFFFFFFF > > The 'autobaud' node must do > $ ip link set canX type can listen-only on > >> >> >> Case 1 both imx6 operate on same CAN baudrate >> cansend can0 -i0x100 11 22 33 44 >> on candump terminal I receive <0x100> [4] 0b 16 21 2c > > Do you use the latest tools from gitorious? > The syntax of cansend and the output of candump look different. > > [...] >> Case 2: imx6 CAN on different baud rate. >> received packets( I am not able to interpret the below packet) >> <0x004> [8] 00 04 00 00 00 00 00 00 > > Well, this is not ok. Ratheendran, what kernel version are you using? Your flexcan driver might have (old) issues. > I'd expect an error or status frame, but I don't see it in your candump > output. Me too, that's weird. > I do notice that the received frame has 8 bytes, and only 1 bit set. > So, if I suppose that the CAN_ERR_FLAG has been set, > I see (with include/linux/can/error.h aside) > <0x004> Controller problem, info in data[1] > > data[1] 04: Reached warning level for RX errors. > > I'd expect something like that. > Wolfgang Grandegger may explain more, as he did author these. Sounds reasonable, also because the rx error counter did reach 128. > Next step is to make a script that does all that, and that makes candump > stop after a limited time (few seconds). > I would suggest to skip a baudrate if you receive any error frame, so the > interpretation may be not necessary. Wolfgang. ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-05-02 11:00 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-24 13:20 detect auto baud rate on can bus in linux driver Ratheendran
2014-04-27 9:44 ` John Whitmore
2014-04-27 18:01 ` Kurt Van Dijck
2014-04-29 8:33 ` Ratheendran S. Rajeshwaran
2014-04-29 8:35 ` Ratheendran S. Rajeshwaran
2014-04-29 19:58 ` Robert Schwebel
[not found] ` <5360E8A6.8040204@tataelxsi.co.in>
2014-04-30 14:41 ` Kurt Van Dijck
2014-04-30 16:35 ` Oliver Hartkopp
2014-05-01 18:49 ` Kurt Van Dijck
[not found] ` <5363243E.7070406@tataelxsi.co.in>
2014-05-02 11:00 ` Kurt Van Dijck
2014-04-29 12:47 ` Heinz-Jürgen Oertel
[not found] ` <535FA7BB.3070700@tataelxsi.co.in>
2014-04-29 14:12 ` Heinz-Jürgen Oertel
[not found] ` <535F5449.7000108@tataelxsi.co.in>
2014-04-29 13:33 ` Kurt Van Dijck
2014-04-29 14:12 ` Wolfgang Grandegger
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.