Skip to content

Commit

Permalink
#56 handle missing head fields, print make/model/serial when available (
Browse files Browse the repository at this point in the history
#57)

* handle missing serial number when marshalling IPC response

* handle missing fields when printing, add make/model/serial
  • Loading branch information
alex-courtis committed Dec 16, 2022
1 parent c162290 commit 68bf6d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
18 changes: 14 additions & 4 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,16 @@ void print_head(enum LogThreshold t, enum InfoEvent event, struct Head *head) {
case NONE:
log_(t, "\n%s%s:", head->name, event == ARRIVED ? " Arrived" : "");
log_(t, " info:");
log_(t, " name: '%s'", head->name);
log_(t, " desc: '%s'", head->description);
if (head->name)
log_(t, " name: '%s'", head->name);
if (head->make)
log_(t, " make: '%s'", head->make);
if (head->model)
log_(t, " model: '%s'", head->model);
if (head->serial_number)
log_(t, " serial: '%s'", head->serial_number);
if (head->description)
log_(t, " desc: '%s'", head->description);
if (head->width_mm && head->height_mm) {
log_(t, " width: %dmm", head->width_mm);
log_(t, " height: %dmm", head->height_mm);
Expand All @@ -264,8 +272,10 @@ void print_head(enum LogThreshold t, enum InfoEvent event, struct Head *head) {
break;
case DEPARTED:
log_(t, "\n%s Departed:", head->name);
log_(t, " name: '%s'", head->name);
log_(t, " desc: '%s'", head->description);
if (head->name)
log_(t, " name: '%s'", head->name);
if (head->description)
log_(t, " desc: '%s'", head->description);
break;
case DELTA:
if (head_current_not_desired(head)) {
Expand Down
15 changes: 10 additions & 5 deletions src/marshalling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,19 @@ YAML::Emitter& operator << (YAML::Emitter& e, struct HeadState& head_state) {

YAML::Emitter& operator << (YAML::Emitter& e, struct Head& head) {

e << YAML::Key << "NAME" << YAML::Value << head.name;
e << YAML::Key << "DESCRIPTION" << YAML::Value << head.description;
if (head.name)
e << YAML::Key << "NAME" << YAML::Value << head.name;
if (head.description)
e << YAML::Key << "DESCRIPTION" << YAML::Value << head.description;
if (head.make)
e << YAML::Key << "MAKE" << YAML::Value << head.make;
if (head.model)
e << YAML::Key << "MODEL" << YAML::Value << head.model;
if (head.serial_number)
e << YAML::Key << "SERIAL_NUMBER" << YAML::Value << head.serial_number;
e << YAML::Key << "WIDTH_MM" << YAML::Value << head.width_mm;
e << YAML::Key << "HEIGHT_MM" << YAML::Value << head.height_mm;
e << YAML::Key << "TRANSFORM" << YAML::Value << head.transform;
e << YAML::Key << "MAKE" << YAML::Value << head.make;
e << YAML::Key << "MODEL" << YAML::Value << head.model;
e << YAML::Key << "SERIAL_NUMBER" << YAML::Value << head.serial_number;

e << YAML::Key << "CURRENT" << YAML::BeginMap; // CURRENT
e << head.current;
Expand Down

0 comments on commit 68bf6d5

Please sign in to comment.