Skip to content

Commit eddfe38

Browse files
authored
Fixed readme for sample projects. Fixed JSON for bacnet objects sub command in shell. (#31)
2 parents 81e04bd + da95ba5 commit eddfe38

File tree

5 files changed

+101
-7
lines changed

5 files changed

+101
-7
lines changed

zephyr/samples/profiles/b-ld/README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,25 @@ Compile this sample for the `rpi_pico` board:
5252
Compile this sample for the `adafruit_grand_central_m4_express` board with
5353

5454
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/
55+
56+
Using the Shell
57+
***************
58+
59+
The shell is available on some boards via virtual communication port:
60+
61+
picocom --baud 115200 /dev/ttyACM0
62+
63+
Terminal ready
64+
*** Booting Zephyr OS build v3.7.0 ***
65+
[00:00:00.012,000] <inf> bacnet: BACnet Device: BACnet Lighting Device (B-LD)
66+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Version 1.4.1
67+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Max APDU: 1476
68+
uart:~$
69+
bacnet clear device devmem help history kernel net
70+
rem resize retval shell stats
71+
uart:~$ bacnet objects
72+
{"object-list": [
73+
{"object-identifier":{"device":4194303}},
74+
{"object-identifier":{"network-port":0}},
75+
{"object-identifier":{"lighting-output":1}}],
76+
"object-list-size": 3}

zephyr/samples/profiles/b-ls/README.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,29 @@ Compile this sample for the `rpi_pico` board:
5858

5959
Compile this sample for the `adafruit_grand_central_m4_express` board with
6060

61-
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/
61+
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ls/
62+
63+
Using the Shell
64+
***************
65+
66+
The shell is available on some boards via virtual communication port:
67+
68+
picocom --baud 115200 /dev/ttyACM0
69+
70+
Terminal ready
71+
*** Booting Zephyr OS build v3.7.0 ***
72+
[00:00:00.012,000] <inf> bacnet: BACnet Device: BACnet Lighting Supervisor (B-LS)
73+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Version 1.4.1
74+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Max APDU: 1476
75+
uart:~$
76+
bacnet clear device devmem help history kernel net
77+
rem resize retval shell stats
78+
uart:~$ bacnet objects
79+
{"object-list": [
80+
{"object-identifier":{"device":260126}},
81+
{"object-identifier":{"network-port":0}},
82+
{"object-identifier":{"lighting-output":1}},
83+
{"object-identifier":{"channel":1}},
84+
{"object-identifier":{"binary-lighting-output":1}}],
85+
"object-list-size": 5}
86+

zephyr/samples/profiles/b-sa/README.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,26 @@ Compile this sample for the `rpi_pico` board:
3333

3434
Compile this sample for the `adafruit_grand_central_m4_express` board with
3535

36-
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/
36+
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-sa/
37+
38+
Using the Shell
39+
***************
40+
41+
The shell is available on some boards via virtual communication port:
42+
43+
picocom --baud 115200 /dev/ttyACM0
44+
45+
Terminal ready
46+
*** Booting Zephyr OS build v3.7.0 ***
47+
[00:00:00.012,000] <inf> bacnet: BACnet Device: BACnet Smart Actuator (B-SA)
48+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Version 1.4.1
49+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Max APDU: 1476
50+
uart:~$
51+
bacnet clear device devmem help history kernel net
52+
rem resize retval shell stats
53+
uart:~$ bacnet objects
54+
{"object-list": [
55+
{"object-identifier":{"device":260124}},
56+
{"object-identifier":{"analog-output":1}},
57+
{"object-identifier":{"network-port":0}}],
58+
"object-list-size": 3}

zephyr/samples/profiles/b-ss/README.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,26 @@ Compile this sample for the `rpi_pico` board:
3333

3434
Compile this sample for the `adafruit_grand_central_m4_express` board with
3535

36-
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ld/
36+
west build -b adafruit_grand_central_m4_express -p always bacnet/zephyr/samples/profiles/b-ss/
37+
38+
Using the Shell
39+
***************
40+
41+
The shell is available on some boards via virtual communication port:
42+
43+
picocom --baud 115200 /dev/ttyACM0
44+
45+
Terminal ready
46+
*** Booting Zephyr OS build v3.7.0 ***
47+
[00:00:00.012,000] <inf> bacnet: BACnet Device: BACnet Smart Sensor (B-SS)
48+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Version 1.4.1
49+
[00:00:00.012,000] <inf> bacnet: BACnet Stack Max APDU: 1476
50+
uart:~$
51+
bacnet clear device devmem help history kernel net
52+
rem resize retval shell stats
53+
uart:~$ bacnet objects
54+
{"object-list": [
55+
{"object-identifier":{"device":4194303}},
56+
{"object-identifier":{"analog-input":1}},
57+
{"object-identifier":{"network-port":0}}],
58+
"object-list-size": 3}

zephyr/subsys/bacnet_shell/bacnet_shell_objects.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ static int cmd_objects(const struct shell *sh, size_t argc, char **argv)
3434

3535
(void)argc;
3636
(void)argv;
37-
shell_print(sh, "List of BACnet Objects: [{");
37+
/* display the object-list as well formed JSON */
38+
shell_print(sh, "{\"%s\": [", bactext_property_name(PROP_OBJECT_LIST));
3839
count = Device_Object_List_Count();
3940
for (array_index = 1; array_index <= count; array_index++) {
4041
found = Device_Object_List_Identifier(array_index, &object_type, &instance);
4142
if (found) {
42-
shell_print(sh, " \"%s-%u\"%c", bactext_object_type_name(object_type),
43-
instance, (array_index == count) ? ' ' : ',');
43+
shell_print(sh, "{\"%s\":{\"%s\":%u}}%s",
44+
bactext_property_name(PROP_OBJECT_IDENTIFIER),
45+
bactext_object_type_name(object_type), instance,
46+
(array_index == count) ? "]," : ",");
4447
}
4548
}
46-
shell_print(sh, "}] -- %d objects found", count);
49+
shell_print(sh, "\"object-list-size\": %d}", count);
4750

4851
return 0;
4952
}

0 commit comments

Comments
 (0)