Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit f5ba51a

Browse files
committed
Established 'xcan' naming throughout project
1 parent 5a5e534 commit f5ba51a

25 files changed

+367
-374
lines changed

.gitignore

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
cmake_install.cmake
2-
CMakeCache.txt
3-
Makefile
4-
CMakeFiles/
5-
XCAN_EXE
1+
build/

CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ project(XCAN VERSION 1.0
55
LANGUAGES C)
66

77
add_executable(XCAN_EXE
8-
modules/can_dev_softdevice.c
9-
modules/can_dev_socketcan.c
10-
stack/can_device.c
11-
stack/can_frame.c
12-
stack/can_stack.c
8+
modules/xcan_dev_softdevice.c
9+
modules/xcan_dev_socketcan.c
10+
stack/xcan_device.c
11+
stack/xcan_frame.c
12+
stack/xcan_stack.c
1313
examples/linux/main.c)
1414

1515
target_include_directories(XCAN_EXE PUBLIC

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# CAN Routing Stack
1+
# XCAN Routing Stack
22

33
## Background
44

5-
CAN is a robust message-based multi-master bus protocol which is particularly dominant in the automotive industry. In large control systems with different domains, there are often several independent CAN buses with each bus connecting together the nodes of a particular domain in the system.
5+
XCAN is a robust message-based multi-master bus protocol which is particularly dominant in the automotive industry. In large control systems with different domains, there are often several independent CAN buses with each bus connecting together the nodes of a particular domain in the system.
66
It is the role of a central **gateway/router** device to pass certain messages between each these buses to enable the sharing of information across domains.
77

8-
This is where the CAN Routing Stack fits in.
8+
This is where the XCAN Routing Stack fits in.
99

10-
The intention of this project is to provide an open-source CAN routing stack.
10+
The intention of this project is to provide an open-source XCAN routing stack.
1111

1212
## Features
1313

@@ -36,7 +36,7 @@ $ sudo ip link add dev vcan0 type vcan
3636
$ sudo ip link add dev vcan1 type vcan
3737
```
3838

39-
Bring up the two vCAN interfaces:
39+
Bring up the two virtual CAN interfaces:
4040
``` shell
4141
$ sudo ip link set up vcan0
4242
$ sudo ip link set up vcan1

examples/linux/main.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
#include <stdio.h>
22
#include <time.h>
33

4-
#include "can_stack.h"
5-
#include "can_dev_socketcan.h"
4+
#include "xcan_stack.h"
5+
#include "xcan_dev_socketcan.h"
66

77

88
int main(int argc, char *argv[])
99
{
10-
struct can_device *dev0, *dev1;
10+
struct xcan_device *dev0, *dev1;
1111

12-
printf("***** XCAN Linux Example *****\n");
12+
printf("***** XXCAN Linux Example *****\n");
1313
printf("Debug: Enabled\n\n");
1414

1515
/* Initialise the XCAN stack */
16-
can_stack_init();
16+
xcan_stack_init();
1717

1818
/* Create the SocketCAN interface 0 */
19-
dev0 = can_socketcan_create(0, "SocketCAN-0");
19+
dev0 = xcan_socketcan_create(0, "SocketCAN-0");
2020
if(!dev0)
2121
return -1;
2222

2323
/* Create the SocketCAN interface 1 */
24-
dev1 = can_socketcan_create(1, "SocketCAN-1");
24+
dev1 = xcan_socketcan_create(1, "SocketCAN-1");
2525
if(!dev1)
2626
return -1;
2727

28-
/* Enter a forever loop, processing CAN frames */
28+
/* Enter a forever loop, processing XCAN frames */
2929
while(1)
3030
{
31-
can_stack_tick();
31+
xcan_stack_tick();
3232
usleep(1000 * 500);
3333
}
3434

modules/can_dev_socketcan.h

-10
This file was deleted.

modules/can_dev_softdevice.c

-65
This file was deleted.

modules/can_dev_softdevice.h

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#include "can_dev_socketcan.h"
1+
#include "xcan_dev_socketcan.h"
22

33
#include "sys/socket.h"
44
#include <linux/can.h>
55
#include <linux/can/raw.h>
66

7-
struct can_device_socketcan {
8-
struct can_device dev;
9-
// Anything else specific to socketcan
7+
struct xcan_device_socketxcan {
8+
struct xcan_device dev;
9+
// Anything else specific to socketxcan
1010
int fd;
1111
};
1212

@@ -15,18 +15,18 @@ struct can_device_socketcan {
1515
/* ======================= PRIVATE ======================= */
1616
/* ================================================================= */
1717

18-
int prv_link_state(struct can_device *dev)
18+
int prv_link_state(struct xcan_device *dev)
1919
{
2020
return 1;
2121
}
2222

23-
int prv_send(struct can_device *self, void *buf, int len)
23+
int prv_send(struct xcan_device *self, void *buf, int len)
2424
{
25-
dbg("CAN sc: Sending %d bytes\n", len);
25+
dbg("XCAN sc: Sending %d bytes\n", len);
2626
return 0;
2727
}
2828

29-
int prv_poll(struct can_device *self, int loop_score)
29+
int prv_poll(struct xcan_device *self, int loop_score)
3030
{
3131

3232
}
@@ -36,25 +36,25 @@ int prv_poll(struct can_device *self, int loop_score)
3636
/* ================================================================= */
3737

3838

39-
void can_socketcan_destroy(struct can_device *dev)
39+
void xcan_socketxcan_destroy(struct xcan_device *dev)
4040
{
41-
struct can_device_socketcan *sc = (struct can_device_socketcan *) dev;
41+
struct xcan_device_socketxcan *sc = (struct xcan_device_socketxcan *) dev;
4242

4343
free(sc);
4444
dbg("Device %s destroyed.\n", sc->dev.name);
4545
}
4646

4747

48-
struct can_device* can_socketcan_create(uint8_t id, char *name)
48+
struct xcan_device* xcan_socketxcan_create(uint8_t id, char *name)
4949
{
50-
struct can_device_socketcan *sc = malloc(sizeof(struct can_device_socketcan));
50+
struct xcan_device_socketxcan *sc = malloc(sizeof(struct xcan_device_socketxcan));
5151

5252
if(!sc)
5353
return NULL;
5454

55-
/* Initialise SocketCAN interface */
55+
/* Initialise SocketXCAN interface */
5656
if((sc->fd = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
57-
dbg("Failed to open socketCAN interface");
57+
dbg("Failed to open socketXCAN interface");
5858
return NULL;
5959
}
6060

@@ -63,19 +63,19 @@ struct can_device* can_socketcan_create(uint8_t id, char *name)
6363
strcpy(ifr.ifr_name, "vcan0");
6464

6565

66-
/* Register SocketCAN interface as XCAN device */
67-
if( 0 != can_device_init((struct can_device *) sc, id, name)) {
66+
/* Register SocketXCAN interface as XXCAN device */
67+
if( 0 != xcan_device_init((struct xcan_device *) sc, id, name)) {
6868

69-
dbg("CAN socketcan init failed.\n");
70-
can_socketcan_destroy((struct can_device*) sc);
69+
dbg("XCAN socketxcan init failed.\n");
70+
xcan_socketxcan_destroy((struct xcan_device*) sc);
7171
return NULL;
7272
}
7373

7474
/* Fill in vtable */
7575
sc->dev.link_state = prv_link_state;
7676
sc->dev.send = prv_send;
7777
sc->dev.poll = prv_poll;
78-
sc->dev.destroy = can_socketcan_destroy;
78+
sc->dev.destroy = xcan_socketxcan_destroy;
7979
dbg("Device %s created\n", name);
80-
return (struct can_device *) sc;
80+
return (struct xcan_device *) sc;
8181
}

modules/xcan_dev_socketcan.h

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef XCAN_DEV_SOCKETXCAN_H
2+
#define XCAN_DEV_SOCKETXCAN_H
3+
4+
#include "xcan_device.h"
5+
6+
void xcan_socketxcan_destroy(struct xcan_device *socketxcan);
7+
8+
struct xcan_device* xcan_socketxcan_create(uint8_t id, char *name);
9+
10+
#endif /* XCAN_DEV_SOCKETXCAN_H */

modules/xcan_dev_softdevice.c

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include "xcan_dev_softdevice.h"
2+
3+
#include <stdio.h>
4+
5+
struct xcan_device_softdevice {
6+
struct xcan_device dev;
7+
// Anything else specific to softdevice
8+
};
9+
10+
11+
/* ================================================================= */
12+
/* ======================= PRIVATE ======================= */
13+
/* ================================================================= */
14+
15+
int prv_link_state(struct xcan_device *dev)
16+
{
17+
return 1;
18+
}
19+
20+
int prv_send(struct xcan_device *self, void *buf, int len)
21+
{
22+
dbg("XCAN SD: Sending %d bytes\n", len);
23+
return 0;
24+
}
25+
26+
int prv_poll(struct xcan_device *self, int loop_score)
27+
{
28+
29+
}
30+
31+
/* ================================================================= */
32+
/* ======================= PUBLIC ======================== */
33+
/* ================================================================= */
34+
35+
36+
void xcan_softdevice_destroy(struct xcan_device *dev)
37+
{
38+
struct xcan_device_softdevice *sd = (struct xcan_device_softdevice *) dev;
39+
40+
free(sd);
41+
dbg("Device %s destroyed.\n", sd->dev.name);
42+
}
43+
44+
45+
struct xcan_device* xcan_softdevice_create(uint8_t id, char *name)
46+
{
47+
struct xcan_device_softdevice *sd = malloc(sizeof(struct xcan_device_softdevice));
48+
49+
if(!sd)
50+
return NULL;
51+
52+
if( 0 != xcan_device_init((struct xcan_device *) sd, id, name)) {
53+
54+
dbg("XCAN SoftDevice init failed.\n");
55+
xcan_softdevice_destroy((struct xcan_device*) sd);
56+
return NULL;
57+
}
58+
59+
sd->dev.link_state = prv_link_state;
60+
sd->dev.send = prv_send;
61+
sd->dev.poll = prv_poll;
62+
sd->dev.destroy = xcan_softdevice_destroy;
63+
dbg("Device %s created\n", name);
64+
return (struct xcan_device *) sd;
65+
}

modules/xcan_dev_softdevice.h

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef XCAN_DEV_SOFTDEVICE_H
2+
#define XCAN_DEV_SOFTDEVICE_H
3+
4+
#include "xcan_device.h"
5+
6+
void xcan_softdevice_destroy(struct xcan_device *softdevice);
7+
8+
struct xcan_device* xcan_softdevice_create(uint8_t id, char *name);
9+
10+
#endif /* XCAN_DEV_SOFTDEVICE_H */

0 commit comments

Comments
 (0)