Skip to content

Commit

Permalink
small fixed to readme and arg-parse
Browse files Browse the repository at this point in the history
Signed-off-by: Kamel Fakih <kamelfakihh@gmail.com>
  • Loading branch information
kamelfakihh committed Nov 19, 2024
1 parent e8b03f2 commit a02cffc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
15 changes: 7 additions & 8 deletions examples/acf-can/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The two applications available in this folder are acf-can-listener and acf-can-talker. These applications can be used along with Linux CAN utilities. On Ubuntu/Debian Linux distributions, these utilities can be installed using the package manager `apt install can-utils`

## acf-can-talker
_acf-can-talker_ receives frames on a (virtual) CAN interface and send out the corresponding IEEE 1722 ACF messages. This application also supports a UDP encapsulation for the IEEE 1722 messages. The parameters for its usage are as follows:
_acf-can-talker_ receives frames on a (virtual) CAN interface and sends out the corresponding IEEE 1722 ACF messages. This application also supports UDP encapsulation for the IEEE 1722 messages. The parameters for its usage are as follows:

```
Usage: acf-can-talker [OPTION...]
Expand Down Expand Up @@ -46,8 +46,9 @@ CAN bus over Ethernet using Open1722.

## Quickstart Tutorial: Tunneling CAN over IEEE 1722 using Linux CAN utilities
Here is an example of how CAN frames can be tunneled over an Ethernet link using _acf-can-talker_ and _acf-can-listener_.
We use two virtual CAN interfaces, _vcan0_ and _vcan1_, here which can be setup using following commands:
We use two virtual CAN interfaces, _vcan0_ and _vcan1_, which can be setup using following commands:
```
$ modprobe vcan
$ ip link add dev vcan0 type vcan # Execute these commands also for vcan1
$ ip link set dev vcan0 up
```
Expand All @@ -71,19 +72,17 @@ $ ./acf-can-talker --dst-addr aa:bb:cc:dd:ee:ff -i eth0 --canif vcan0
```

### Use Listener Application for receiving
On Terminal 3, receive the IEEE 1722 traffic using _acf-can-listener_ for putting the CAN frame out on vcan1.
On Terminal 3, receive the IEEE 1722 traffic using _acf-can-listener_ and put the CAN frame out on vcan1.

If the talke uses UDP encapsulation:
If the talker uses UDP encapsulation:
```
$ acf-can-listener -u -p 17220 --canif vcan1
$ ./acf-can-listener -u -p 17220 --canif vcan1
```

Alternatively, if Ethernet is directly used:
```
$ ./acf-can-listener --dst-addr aa:bb:cc:dd:ee:ff -i eth0 --canif vcan0
```

You can now compare CAN traffic seen on _vcan0 and vcan1_, if the tunneling has worked.
You can now compare CAN traffic seen on _vcan0 and vcan1_ to check if the tunneling works.
Note that the tunneling works in these examples only in one direction (_vcan0_ -> _vcan1_).


6 changes: 3 additions & 3 deletions examples/acf-can/acf-can-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ static char doc[] =
\vEXAMPLES\n\
acf-can-listener -i eth0 -d aa:bb:cc:dd:ee:ff --canif can1\n\
\t(tunnel Open1722 CAN messages received from eth0 to can1)\n\
acf-can-listener --canif can1 -u -p 1722\n\
\t(tunnel Open1722 CAN messages received over UDP from port 1722 to can1)";
acf-can-listener --canif can1 -u -p 17220\n\
\t(tunnel Open1722 CAN messages received over UDP from port 17220 to can1)";

static struct argp_option options[] = {
{"udp", 'u', 0, 0, "Use UDP" },
Expand Down Expand Up @@ -112,7 +112,7 @@ static error_t parser(int key, char *arg, struct argp_state *state)
return 0;
}

static struct argp argp = { options, parser };
static struct argp argp = { options, parser, NULL, doc};

static int is_valid_acf_packet(uint8_t* acf_pdu)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/acf-can/acf-can-talker.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static error_t parser(int key, char *arg, struct argp_state *state)
return 0;
}

static struct argp argp = { options, parser};
static struct argp argp = { options, parser, NULL, doc};

static int init_cf_pdu(uint8_t* pdu)
{
Expand Down Expand Up @@ -223,7 +223,7 @@ int main(int argc, char *argv[])
uint16_t pdu_length, cf_length;
frame_t can_frame;

argp_parse(&argp, argc, argv, 0, NULL, NULL);
argp_parse(&argp, argc, argv, doc, NULL, NULL);

// Create an appropriate talker socket: UDP or Ethernet raw
// Setup the socket for sending to the destination
Expand Down

0 comments on commit a02cffc

Please sign in to comment.