Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a protobuf sync message every 64 messages #483

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sudo apt-get install python3.6 -y
sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.6 /usr/bin/python3
wget https://bootstrap.pypa.io/get-pip.py
wget https://bootstrap.pypa.io/pip/3.6/get-pip.py
sudo python3 get-pip.py
sudo apt-get install -qq -y libsubunit-dev
sudo apt-get install python-apt
Expand Down
19 changes: 19 additions & 0 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ void openxc::pipeline::publish(openxc_VehicleMessage* message,
} else {
debug("Trying to serialize unrecognized type: %d", message->type);
}

// Send a SYNC Message Jan 2022!!!

static int msgCounter = 0;
if ((msgCounter & 0x3f) == 0x3f) { // Send a sync message every 63 messages
sendSyncMessage(pipeline);
}
msgCounter++;
}

void openxc::pipeline::sendMessage(Pipeline* pipeline, uint8_t* message,
Expand Down Expand Up @@ -314,3 +322,14 @@ void openxc::pipeline::logStatistics(Pipeline* pipeline) {
}
}
}


void openxc::pipeline::sendSyncMessage(Pipeline* pipeline) {
unsigned char syncMessagePayload[] = {0x07, 'S', 'Y', 'N', 'C', 'M', 'S', 'G' };

MessageClass messageClass = MessageClass::CAN;

sendMessage(pipeline, syncMessagePayload, sizeof(syncMessagePayload), messageClass);
debug("Sent Sync Message");

}
1 change: 1 addition & 0 deletions src/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void sendMessage(Pipeline* pipeline, uint8_t* message, int messageSize,
void process(Pipeline* pipeline);

void logStatistics(Pipeline* pipeline);
void sendSyncMessage(Pipeline* pipeline);

} // namespace interface
} // namespace openxc
Expand Down