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

Commit 63f8e8b

Browse files
committed
Added debug print macro
1 parent f1e5e39 commit 63f8e8b

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

modules/can_dev_softdevice.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ struct can_device_softdevice {
1212
/* ======================= PRIVATE ======================= */
1313
/* ================================================================= */
1414

15-
int link_state(struct can_device *dev)
15+
int prv_link_state(struct can_device *dev)
1616
{
1717
return 1;
1818
}
1919

20-
int send(struct can_device *self, void *buf, int len)
20+
int prv_send(struct can_device *self, void *buf, int len)
2121
{
22-
printf("CAN SD: Sending %d bytes\n", len);
22+
dbg("CAN SD: Sending %d bytes\n", len);
2323
return 0;
2424
}
2525

26-
int poll(struct can_device *self, int loop_score)
26+
int prv_poll(struct can_device *self, int loop_score)
2727
{
2828

2929
}
@@ -38,7 +38,7 @@ void can_softdevice_destroy(struct can_device *dev)
3838
struct can_device_softdevice *sd = (struct can_device_softdevice *) dev;
3939

4040
free(sd);
41-
printf("Device %s destroyed.\n", sd->dev.name);
41+
dbg("Device %s destroyed.\n", sd->dev.name);
4242
}
4343

4444

@@ -51,15 +51,15 @@ struct can_device* can_softdevice_create(uint8_t id, char *name)
5151

5252
if( 0 != can_device_init((struct can_device *) sd, id, name)) {
5353

54-
printf("CAN SoftDevice init failed.\n");
54+
dbg("CAN SoftDevice init failed.\n");
5555
can_softdevice_destroy((struct can_device*) sd);
5656
return NULL;
5757
}
5858

59-
sd->dev.link_state = link_state;
60-
sd->dev.send = send;
61-
sd->dev.poll = poll;
62-
sd->dev.destroy = can_softdevice_destroy;
63-
printf("Device %s created\n", name);
59+
sd->dev.link_state = prv_link_state;
60+
sd->dev.send = prv_send;
61+
sd->dev.poll = prv_poll;
62+
sd->dev.destroy = can_softdevice_destroy;
63+
dbg("Device %s created\n", name);
6464
return (struct can_device *) sd;
6565
}

stack/can_device.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ int can_device_init(struct can_device *dev, uint8_t id, const char *name)
2323

2424
/* Register device with device pool */
2525
devices[id] = dev;
26+
return 0;
2627
}
2728

2829

@@ -35,6 +36,7 @@ void can_device_destroy(struct can_device *dev)
3536
int can_devices_loop(int loop_score, int direction)
3637
{
3738
/** @todo */
39+
return 0;
3840
}
3941

4042
struct can_device* can_get_device(uint8_t id)
@@ -46,4 +48,4 @@ struct can_device* can_get_device(uint8_t id)
4648
int can_device_link_state(struct can_device *dev)
4749
{
4850
return dev->link_state(dev);
49-
}
51+
}

stack/include/can_config.h

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
#include <linux/types.h>
1212
#endif /* __KERNEL__ */
1313

14+
#ifdef DEBUG
15+
#include <stdio.h>
16+
#define dbg(f, ...) printf(f, ...)
17+
#else
18+
#define dbg(...)
19+
#endif
20+
1421
#define CAN_ZALLOC(x) calloc(x, 0)
1522
#define CAN_FREE(x) free(x)
1623

0 commit comments

Comments
 (0)