canltwo.tcl
来自「can4linux-3.5.3.gz can4 linux」· TCL 代码 · 共 47 行
TCL
47 行
#!/usr/bin/tclsh# Tcl CAN Layer 2 example#load ./canLtwo.soputs "....... swig wrapper loaded"# open the can interface /dev/can0# but before, set the baud rate if other than defaultexec /bin/echo 125 > /proc/sys/Can/Baudputs "....... bit rate changed"set device 1set can_fd [can_open $device]puts "....... /dev/can$device opened"# send 8 byte, message id 100can_send $can_fd 8 100:1,2,3,4,5,6,7,8puts "... sent message"# don't specify message lengthcan_send $can_fd 0 100:8,7,6,5,4,3,2,1puts "... sent message"# send RTR messagescan_send $can_fd 0 r200puts "... sent message"can_send $can_fd 4 r101puts "... sent message"set timeout 10# try to receive something from can_fd, timeout in 祍# wait forever if timeout == 0puts "Wait $timeout sec for an message....."puts [can_read2 $can_fd [expr $timeout * 1000000]]puts "Wait $timeout sec for an message....."puts [can_read1 $can_fd [expr $timeout * 1000000]]puts "Wait default timeout for an message....."puts [can_read1 $can_fd]can_close $can_fdputs "....... /dev/can$device closed"exit
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?