Recent

Author Topic: CAN-BUS SocketCAN  (Read 73199 times)

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #150 on: November 24, 2021, 08:49:50 am »
I'm in the middle of making a T-cable to tap into a live system, which needs a couple of moderately-expensive connectors
There are contactless crocodile clips which can be used if you only need to spy data without sending anything (like just spying J1939):
https://copperhilltech.com/cancrocodile-contactless-can-bus-j1708-reader/

or tap into cable system without connectors using intrusive T splitters:
https://www.aliexpress.com/item/4001147302536.html

You might also use thin needles hack to tap into the system without a need for an expensive connector.

Of course, nothing like a real thing. But these days receiving products from online ordering can take forever.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

MarkMLl

  • Hero Member
  • *****
  • Posts: 6692
Re: CAN-BUS SocketCAN
« Reply #151 on: November 24, 2021, 09:11:11 am »
I've got the connectors, just need steel myself for the crimping... it's a one-time assembly with environmental seals etc.

£20 for a pair isn't too bad, considering. But in principle it should be possible to have a stock of "close enough" pins and receptacles and 3D-print the housings on demand.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

unoAchtung

  • Newbie
  • Posts: 2
Re: CAN-BUS SocketCAN
« Reply #152 on: October 20, 2022, 03:13:13 pm »
Impressive work!

How do I do if I want to find out which channels that are available on the device (can0, can1, etc.)?

jcdammeyer

  • Full Member
  • ***
  • Posts: 205
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #153 on: October 20, 2022, 06:26:28 pm »
Boy it's been over a year since I did anything with this.  Work-work and COVID shutdows got in the way.  In a few months I should be able to get back to this project.  I've pretty well abandoned the BeagleBone Black.  The OS just keeps changing with respect to I/O breaking existing code. 

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #154 on: October 22, 2022, 01:40:57 pm »
Impressive work!
Thanks!  ;)

How do I do if I want to find out which channels that are available on the device (can0, can1, etc.)?
Using ifconfig from net-tools package can show CAN device interfaces that you have already brought up:
Code: Pascal  [Select][+][-]
  1. ifconfig | grep can
but beware that out of the box linux does not bring any interfaces automatically. You have to do it on your own if there is no vendor script for that purpose. You can find relevant tutorials in my initial posts.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

unoAchtung

  • Newbie
  • Posts: 2
Re: CAN-BUS SocketCAN
« Reply #155 on: October 24, 2022, 09:55:16 am »
If I want to list the devices in my FPC application, how can I get the devices through FPC code?

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #156 on: October 24, 2022, 11:17:31 am »
If I want to list the devices in my FPC application, how can I get the devices through FPC code?
Either asume that ifconfig is installed and each CAN interface has CAN word in it's name so you can use output of this command line:
Code: Pascal  [Select][+][-]
  1. avra@vm-debian:~$ ifconfig | grep can | sed -r 's#:.*##'
  2. vcan0
  3. vcan1
or analyze source code of ifconfig and try to replicate part of it's functionality in pascal:
https://github.com/giftnuss/net-tools/blob/master/ifconfig.c

EDIT:

Ok, I was playing a little so here is version 2 which still depends on net-tools package and CAN substring in interface name:
Code: Pascal  [Select][+][-]
  1. avra@vm-debian:~$ netstat -i | grep can | sed -r 's# .*##'
  2. vcan0
  3. vcan1
and version 3 which lists all can, vcan and vxcan interfaces without depending on net-tools package or CAN substring in their name:
Code: Pascal  [Select][+][-]
  1. avra@vm-debian:~$ ip link show type can | grep : | sed -r 's#: <.*##' | sed -r 's#.* ##' && ip link show type vcan | grep : | sed -r 's#: <.*##' | sed -r 's#.* ##' && ip link show type vxcan | grep : | sed -r 's#: <.*##' | sed -r 's#.* ##'
  2. vcan0
  3. vcan1

As you can guess, of all command lines version 3 is the best since ip command exists in most modern distros (iproute2 package). However, you should not asume anything and always do the checking on your own.
« Last Edit: October 24, 2022, 12:50:43 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018