创新can调试器Linux版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
6.1 KiB

4 years ago
  1. //第一步:打开controlcan文件夹中的Makefile文件,修改文件中的相应的路径:g++ -o hello_cpp main.cpp /home/ttc/Desktop/controlcan/libcontrolcan.so -lpthread
  2. (按实际路径修改)
  3. //以下部份为查看系统信息。可省略。
  4. ttc@ubuntu:~$ uname -a
  5. Linux ubuntu 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux
  6. ttc@ubuntu:~$
  7. ttc@ubuntu:~$ gcc -v
  8. Using built-in specs.
  9. COLLECT_GCC=gcc
  10. COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/5/lto-wrapper
  11. Target: i686-linux-gnu
  12. Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.3.1-14ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-i386/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-i386 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-i386 --with-arch-directory=i386 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-targets=all --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
  13. Thread model: posix
  14. gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2)
  15. ttc@ubuntu:~$
  16. //以上部份为查看系统信息。可省略。
  17. //以下命令是查看USB设备信息,插上USB即可查找到ID 04d8:0053 Microchip Technology, Inc. 设备,无需安装USB驱动。USB驱动已集成在二次开发库中。
  18. ttc@ubuntu:~$ lsusb
  19. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  20. Bus 002 Device 004: ID 04d8:0053 Microchip Technology, Inc.
  21. Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
  22. Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
  23. Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
  24. ttc@ubuntu:~$
  25. //以上命令是查看USB设备信息,插上USB即可查找到ID 04d8:0053 Microchip Technology, Inc. 设备,无需安装USB驱动。USB驱动已集成在二次开发库中。
  26. //将controlcan文件夹放在桌面。把CAN1与CAN2对接,运行后,可以看到程序内置的发送数据,被另一个通道接收。
  27. ttc@ubuntu:~$ ls
  28. Desktop Downloads Music Public Videos
  29. Documents examples.desktop Pictures Templates
  30. ttc@ubuntu:~$ cd \Desktop
  31. ttc@ubuntu:~/Desktop$
  32. ttc@ubuntu:~/Desktop$ ls
  33. controlcan
  34. ttc@ubuntu:~/Desktop$
  35. ttc@ubuntu:~/Desktop$ cd \controlcan
  36. ttc@ubuntu:~/Desktop/controlcan$
  37. ttc@ubuntu:~/Desktop/controlcan$ ls
  38. controlcan.h hello_cpp libcontrolcan.so main.cpp Makefile
  39. ttc@ubuntu:~/Desktop/controlcan$ rm hello_cpp
  40. ttc@ubuntu:~/Desktop/controlcan$
  41. ttc@ubuntu:~/Desktop/controlcan$ ls
  42. controlcan.h libcontrolcan.so main.cpp Makefile
  43. ttc@ubuntu:~/Desktop/controlcan$
  44. ttc@ubuntu:~/Desktop/controlcan$ gedit main.cpp
  45. //在此处修改测试样例程序C代码。main.cpp
  46. //保存,关闭C代码。main.cpp
  47. ttc@ubuntu:~/Desktop/controlcan$
  48. ttc@ubuntu:~/Desktop/controlcan$ ls
  49. controlcan.h libcontrolcan.so main.cpp Makefile
  50. ttc@ubuntu:~/Desktop/controlcan$
  51. ttc@ubuntu:~/Desktop/controlcan$ make clean && make
  52. rm -f *.o hello
  53. #gcc -o hello -L. -lcontrolcan -lpthread -lusb main.c
  54. #arm-none-linux-gnueabi-gcc -o hello -L. -L /home/caidunqing/controlcan -lcontrolcan -lpthread main.c
  55. g++ -o hello_cpp main.cpp /home/ttc/Desktop/controlcan/libcontrolcan.so -lpthread
  56. ttc@ubuntu:~/Desktop/controlcan$ sudo ./hello_cpp
  57. [sudo] password for ttc:
  58. >>this is hello !
  59. >>open deivce success!
  60. >>Get VCI_ReadBoardInfo success!
  61. >>Serial_Num:01701019000
  62. >>hw_Type:CAN-Linux
  63. Index:0000 CAN1 TX ID:0x00000000 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  64. Index:0001 CAN2 TX ID:0x00000001 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  65. Index:0002 CAN1 TX ID:0x00000002 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  66. Index:0003 CAN2 TX ID:0x00000003 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  67. Index:0004 CAN1 TX ID:0x00000004 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  68. Index:0005 CAN2 TX ID:0x00000005 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  69. Index:0006 CAN1 TX ID:0x00000006 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  70. Index:0007 CAN2 RX ID:0x00000000 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA867
  71. Index:0008 CAN1 RX ID:0x00000001 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA877
  72. Index:0009 CAN2 TX ID:0x00000007 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  73. Index:0010 CAN1 TX ID:0x00000008 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  74. Index:0011 CAN2 TX ID:0x00000009 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07
  75. Index:0012 CAN2 RX ID:0x00000002 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA882
  76. Index:0013 CAN2 RX ID:0x00000004 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA89A
  77. Index:0014 CAN1 RX ID:0x00000003 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA88E
  78. Index:0015 CAN1 RX ID:0x00000005 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA8A5
  79. Index:0016 CAN1 RX ID:0x00000007 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA8BD
  80. Index:0017 CAN2 RX ID:0x00000006 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA8B1
  81. Index:0018 CAN2 RX ID:0x00000008 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA8C8
  82. Index:0019 CAN1 RX ID:0x00000009 Extend Data DLC:0x08 data:0x 00 01 02 03 04 05 06 07 TimeStamp:0x065FA8D4
  83. run thread exit
  84. ttc@ubuntu:~/Desktop/controlcan$