Add extracted tools: CitrineOS, OpenOCPP, ShapeShifter

- CitrineOS core extracted (CSMS OCPP 2.0.1)
- OpenOCPP extracted (firmware OCPP 1.6J/2.0.1)
- ShapeShifter library installed (pip install -e)
- ShapeShifter specification extracted
- EVerest extracted

TODO updated with progress
This commit is contained in:
Eric F
2026-06-08 00:38:27 -04:00
parent 468cfeaa50
commit d398a6ced2
7326 changed files with 1177561 additions and 7 deletions

View File

@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.10)
# set the project name
project(evyeti_comms VERSION 0.1)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
configure_file(config.h.in config.h)
# add the executable
add_library(evyeti_comms STATIC)
ev_register_library_target(evyeti_comms)
target_sources(evyeti_comms
PRIVATE
evSerial.cpp
protobuf/hi2lo.pb.c
protobuf/lo2hi.pb.c
)
target_include_directories(evyeti_comms
PUBLIC
"${PROJECT_BINARY_DIR}"
protobuf
)
target_link_libraries(evyeti_comms
PUBLIC
date::date-tz
everest::nanopb
PRIVATE
Pal::Sigslot
everest::framework
)

View File

@@ -0,0 +1,3 @@
// the configured options and settings for YetiDriver
#define YetiComms_VERSION_MAJOR @YetiComms_VERSION_MAJOR@
#define YetiComms_VERSION_MINOR @YetiComms_VERSION_MINOR@

View File

@@ -0,0 +1,399 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
#include "evSerial.h"
#include <cerrno>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
#include <thread>
#include <fcntl.h>
#include <unistd.h>
#include <date/date.h>
#include <date/tz.h>
#include <everest/3rd_party/nanopb/pb_decode.h>
#include <everest/3rd_party/nanopb/pb_encode.h>
#include "hi2lo.pb.h"
#include "lo2hi.pb.h"
evSerial::evSerial() {
fd = 0;
baud = 0;
reset_done_flag = false;
forced_reset = false;
cobsDecodeReset();
}
evSerial::~evSerial() {
if (fd)
close(fd);
}
bool evSerial::openDevice(const char* device, int _baud) {
fd = open(device, O_RDWR | O_NOCTTY | O_SYNC);
if (fd < 0) {
printf("Serial: error %d opening %s: %s\n", errno, device, strerror(errno));
return false;
} // else printf ("Serial: opened %s as %i\n", device, fd);
cobsDecodeReset();
switch (_baud) {
case 9600:
baud = B9600;
break;
case 19200:
baud = B19200;
break;
case 38400:
baud = B38400;
break;
case 57600:
baud = B57600;
break;
case 115200:
baud = B115200;
break;
case 230400:
baud = B230400;
break;
default:
baud = 0;
return false;
}
return setSerialAttributes();
}
bool evSerial::setSerialAttributes() {
struct termios tty;
if (tcgetattr(fd, &tty) != 0) {
printf("Serial: error %d from tcgetattr\n", errno);
return false;
}
cfsetospeed(&tty, baud);
cfsetispeed(&tty, baud);
tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; // 8-bit chars
// disable IGNBRK for mismatched speed tests; otherwise receive break
// as \000 chars
tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY);
tty.c_lflag = 0; // no signaling chars, no echo,
// no canonical processing
tty.c_oflag = 0; // no remapping, no delays
tty.c_cc[VMIN] = 0; // read blocks
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
tty.c_cflag |= (CLOCAL | CREAD); // ignore modem controls,
// enable reading
tty.c_cflag &= ~(PARENB | PARODD); // shut off parity
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CRTSCTS;
if (tcsetattr(fd, TCSANOW, &tty) != 0) {
printf("Serial: error %d from tcsetattr\n", errno);
return false;
}
// printf ("Success setting tcsetattr\n");
return true;
}
void evSerial::cobsDecodeReset() {
code = 0xff;
block = 0;
decode = msg;
}
uint32_t evSerial::crc32(uint8_t* buf, int len) {
int i, j;
uint32_t b, crc, msk;
i = 0;
crc = 0xFFFFFFFF;
while (i < len) {
b = buf[i];
crc = crc ^ b;
for (j = 7; j >= 0; j--) {
msk = -(crc & 1);
crc = (crc >> 1) ^ (0xEDB88320 & msk);
}
i = i + 1;
}
// printf("%X",crc);
return crc;
}
void evSerial::handlePacket(uint8_t* buf, int len) {
// printf ("packet received len %u\n", len);
// Check CRC32 (last 4 bytes)
// uint32_t crc = calculateCrc(rx_packet_buf, rx_packet_len);
if (crc32(buf, len)) {
printf("CRC mismatch\n");
return;
}
len -= 4;
LoToHi msg_in;
pb_istream_t istream = pb_istream_from_buffer(buf, len);
if (pb_decode(&istream, LoToHi_fields, &msg_in))
switch (msg_in.which_payload) {
case LoToHi_keep_alive_tag:
// printf("Received keep_alive_lo\n");
signalKeepAliveLo(msg_in.payload.keep_alive);
// detect connection timeout if keep_alive packets stop coming...
last_keep_alive_lo_timestamp = date::utc_clock::now();
break;
case LoToHi_event_tag:
// printf("Received event %i\n",msg_in.payload.event);
signalEvent(msg_in.payload.event);
break;
case LoToHi_measurements_tag:
// printf("Received event %i\n",msg_in.payload.event);
signalMeasurements(msg_in.payload.measurements);
break;
case LoToHi_reset_done_tag:
// printf("Received reset_done\n");
reset_done_flag = true;
if (!forced_reset)
signalSpuriousReset();
break;
}
}
void evSerial::cobsDecode(uint8_t* buf, int len) {
for (int i = 0; i < len; i++)
cobsDecodeByte(buf[i]);
}
void evSerial::cobsDecodeByte(uint8_t byte) {
// check max length
if ((decode - msg == 2048 - 1) && byte != 0x00) {
printf("cobsDecode: Buffer overflow\n");
cobsDecodeReset();
}
if (block) {
// we're currently decoding and should not get a 0
if (byte == 0x00) {
// probably found some garbage -> reset
printf("cobsDecode: Garbage detected\n");
cobsDecodeReset();
return;
}
*decode++ = byte;
} else {
if (code != 0xff) {
*decode++ = 0;
}
block = code = byte;
if (code == 0x00) {
// we're finished, reset everything and commit
if (decode == msg) {
// we received nothing, just a 0x00
printf("cobsDecode: Received nothing\n");
} else {
// set back decode with one, as it gets post-incremented
handlePacket(msg, decode - 1 - msg);
}
cobsDecodeReset();
return; // need to return here, because of block--
}
}
block--;
}
void evSerial::run() {
readThreadHandle = std::thread(&evSerial::readThread, this);
timeoutDetectionThreadHandle = std::thread(&evSerial::timeoutDetectionThread, this);
}
void evSerial::timeoutDetectionThread() {
while (true) {
sleep(1);
if (timeoutDetectionThreadHandle.shouldExit())
break;
if (serial_timed_out())
signalConnectionTimeout();
}
}
void evSerial::readThread() {
uint8_t buf[2048];
int n;
cobsDecodeReset();
while (true) {
if (readThreadHandle.shouldExit())
break;
if (fd > 0) {
n = read(fd, buf, sizeof buf);
cobsDecode(buf, n);
}
}
}
bool evSerial::linkWrite(HiToLo* m) {
if (fd <= 0) {
return false;
}
uint8_t tx_packet_buf[1024];
uint8_t encode_buf[1500];
pb_ostream_t ostream = pb_ostream_from_buffer(tx_packet_buf, sizeof(tx_packet_buf) - 4);
bool status = pb_encode(&ostream, HiToLo_fields, m);
if (!status) {
// couldn't encode
return false;
}
size_t tx_payload_len = ostream.bytes_written;
// add crc32 (CRC-32/JAMCRC)
uint32_t crc = crc32(tx_packet_buf, tx_payload_len);
for (int byte_pos = 0; byte_pos < 4; ++byte_pos) {
tx_packet_buf[tx_payload_len] = (uint8_t)crc & 0xFF;
crc = crc >> 8;
tx_payload_len++;
}
size_t tx_encode_len = cobsEncode(tx_packet_buf, tx_payload_len, encode_buf);
// std::cout << "Write "<<tx_encode_len<<" bytes to serial port." << std::endl;
write(fd, encode_buf, tx_encode_len);
return true;
}
size_t evSerial::cobsEncode(const void* data, size_t length, uint8_t* buffer) {
uint8_t* encode = buffer; // Encoded byte pointer
uint8_t* codep = encode++; // Output code pointer
uint8_t code = 1; // Code value
for (const uint8_t* byte = (const uint8_t*)data; length--; ++byte) {
if (*byte) // Byte not zero, write it
*encode++ = *byte, ++code;
if (!*byte || code == 0xff) // Input is zero or block completed, restart
{
*codep = code, code = 1, codep = encode;
if (!*byte || length)
++encode;
}
}
*codep = code; // Write final code value
// add final 0
*encode++ = 0x00;
return encode - buffer;
}
bool evSerial::serial_timed_out() {
auto now = date::utc_clock::now();
auto timeSinceLastKeepAlive =
std::chrono::duration_cast<std::chrono::milliseconds>(now - last_keep_alive_lo_timestamp).count();
if (timeSinceLastKeepAlive >= 5000)
return true;
return false;
}
void evSerial::allowPowerOn(bool p) {
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_allow_power_on_tag;
msg_out.payload.allow_power_on.p = p;
linkWrite(&msg_out);
}
void evSerial::setBCDE(uint32_t mode) {
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_set_bcde_tag;
msg_out.payload.set_bcde.mode = mode;
linkWrite(&msg_out);
}
void evSerial::enable() {
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_enable_tag;
linkWrite(&msg_out);
}
void evSerial::disable() {
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_disable_tag;
linkWrite(&msg_out);
}
bool evSerial::reset(const int reset_pin) {
reset_done_flag = false;
forced_reset = true;
if (reset_pin > 0) {
// Try to hardware reset Yeti controller to be in a known state
char cmd[100];
sprintf(cmd, "echo %i >/sys/class/gpio/export", reset_pin);
system(cmd);
sprintf(cmd, "echo out > /sys/class/gpio/gpio%i/direction", reset_pin);
system(cmd);
sprintf(cmd, "echo 0 > /sys/class/gpio/gpio%i/value", reset_pin);
system(cmd);
sprintf(cmd, "echo 1 > /sys/class/gpio/gpio%i/value", reset_pin);
system(cmd);
} else {
// Try to soft reset Yeti controller to be in a known state
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_reset_tag;
linkWrite(&msg_out);
}
bool success = false;
// Wait for reset done message from uC
for (int i = 0; i < 20; i++) {
if (reset_done_flag) {
success = true;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
// Reset flag to detect run time spurious resets of uC from now on
reset_done_flag = false;
forced_reset = false;
// send some dummy packets to resync COBS etc.
keepAlive();
keepAlive();
keepAlive();
return success;
}
void evSerial::firmwareUpdate(bool rom) {
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_firmware_update_tag;
msg_out.payload.firmware_update.invoke_rom_bootloader = rom;
linkWrite(&msg_out);
}
void evSerial::keepAlive() {
HiToLo msg_out = HiToLo_init_default;
msg_out.which_payload = HiToLo_keep_alive_tag;
msg_out.payload.keep_alive.time_stamp = 0;
msg_out.payload.keep_alive.hw_type = 0;
msg_out.payload.keep_alive.hw_revision = 0;
msg_out.payload.keep_alive.protocol_version_major = 0;
msg_out.payload.keep_alive.protocol_version_minor = 1;
strcpy(msg_out.payload.keep_alive.sw_version_string, "n/a");
linkWrite(&msg_out);
}

View File

@@ -0,0 +1,76 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2021 Pionix GmbH and Contributors to EVerest
#ifndef YETI_SERIAL
#define YETI_SERIAL
#include "hi2lo.pb.h"
#include "lo2hi.pb.h"
#include <date/date.h>
#include <date/tz.h>
#include <sigslot/signal.hpp>
#include <stdint.h>
#include <termios.h>
#include <utils/thread.hpp>
class evSerial {
public:
evSerial();
~evSerial();
bool openDevice(const char* device, int baud);
bool is_open() {
return fd > 0;
};
void readThread();
void run();
void enable();
void disable();
void firmwareUpdate(bool rom);
void keepAlive();
bool reset(const int reset_pin);
void setBCDE(uint32_t mode);
void allowPowerOn(bool p);
sigslot::signal<KeepAliveLo> signalKeepAliveLo;
sigslot::signal<Event> signalEvent;
sigslot::signal<Measurements> signalMeasurements;
sigslot::signal<> signalSpuriousReset;
sigslot::signal<> signalConnectionTimeout;
private:
// Serial interface
bool setSerialAttributes();
int fd;
int baud;
// COBS de-/encoder
void cobsDecodeReset();
void handlePacket(uint8_t* buf, int len);
void cobsDecode(uint8_t* buf, int len);
void cobsDecodeByte(uint8_t byte);
size_t cobsEncode(const void* data, size_t length, uint8_t* buffer);
uint8_t msg[2048];
uint8_t code;
uint8_t block;
uint8_t* decode;
uint32_t crc32(uint8_t* buf, int len);
// Read thread for serial port
Everest::Thread readThreadHandle;
Everest::Thread timeoutDetectionThreadHandle;
bool linkWrite(HiToLo* m);
volatile bool reset_done_flag;
volatile bool forced_reset;
bool serial_timed_out();
void timeoutDetectionThread();
std::chrono::time_point<date::utc_clock> last_keep_alive_lo_timestamp;
};
#endif

View File

@@ -0,0 +1,2 @@
#!/bin/sh
nanopb_generator.py -L "#include <nanopb/%s>" -I . -D . lo2hi.proto hi2lo.proto

View File

@@ -0,0 +1 @@
KeepAliveHi.sw_version_string max_length:50

View File

@@ -0,0 +1,33 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.6 */
#include "hi2lo.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
PB_BIND(HiToLo, HiToLo, AUTO)
PB_BIND(AllowPowerOn, AllowPowerOn, AUTO)
PB_BIND(SetBCDE, SetBCDE, AUTO)
PB_BIND(FirmwareUpdate, FirmwareUpdate, AUTO)
PB_BIND(KeepAliveHi, KeepAliveHi, AUTO)
PB_BIND(Enable, Enable, AUTO)
PB_BIND(Disable, Disable, AUTO)
PB_BIND(Reset, Reset, AUTO)

View File

@@ -0,0 +1,196 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.6 */
#ifndef PB_HI2LO_PB_H_INCLUDED
#define PB_HI2LO_PB_H_INCLUDED
#include <everest/3rd_party/nanopb/pb.h>
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
/* Struct definitions */
typedef struct _Disable {
char dummy_field;
} Disable;
typedef struct _Enable {
char dummy_field;
} Enable;
typedef struct _Reset {
char dummy_field;
} Reset;
typedef struct _AllowPowerOn {
bool p;
} AllowPowerOn;
typedef struct _FirmwareUpdate {
bool invoke_rom_bootloader;
} FirmwareUpdate;
typedef struct _KeepAliveHi {
uint32_t time_stamp;
uint32_t hw_type;
uint32_t hw_revision;
uint32_t protocol_version_major;
uint32_t protocol_version_minor;
char sw_version_string[51];
} KeepAliveHi;
typedef struct _SetBCDE {
int32_t mode; /* 0: A, 1: B, 2: C, 3: D, 4: E */
} SetBCDE;
/* This container message is send from Hi Level to Low level and may contain any allowed message in that direction. */
typedef struct _HiToLo {
pb_size_t which_payload;
union {
/* Common/configuration messages */
Enable enable;
Disable disable;
KeepAliveHi keep_alive;
FirmwareUpdate firmware_update;
AllowPowerOn allow_power_on;
/* Commands for HIL simulator */
Reset reset;
/* Commands only available in control_mode = 2 (direct low level control) */
SetBCDE set_bcde;
} payload;
} HiToLo;
#ifdef __cplusplus
extern "C" {
#endif
/* Initializer values for message structs */
#define HiToLo_init_default {0, {Enable_init_default}}
#define AllowPowerOn_init_default {0}
#define SetBCDE_init_default {0}
#define FirmwareUpdate_init_default {0}
#define KeepAliveHi_init_default {0, 0, 0, 0, 0, ""}
#define Enable_init_default {0}
#define Disable_init_default {0}
#define Reset_init_default {0}
#define HiToLo_init_zero {0, {Enable_init_zero}}
#define AllowPowerOn_init_zero {0}
#define SetBCDE_init_zero {0}
#define FirmwareUpdate_init_zero {0}
#define KeepAliveHi_init_zero {0, 0, 0, 0, 0, ""}
#define Enable_init_zero {0}
#define Disable_init_zero {0}
#define Reset_init_zero {0}
/* Field tags (for use in manual encoding/decoding) */
#define AllowPowerOn_p_tag 1
#define FirmwareUpdate_invoke_rom_bootloader_tag 1
#define KeepAliveHi_time_stamp_tag 1
#define KeepAliveHi_hw_type_tag 2
#define KeepAliveHi_hw_revision_tag 3
#define KeepAliveHi_protocol_version_major_tag 4
#define KeepAliveHi_protocol_version_minor_tag 5
#define KeepAliveHi_sw_version_string_tag 6
#define SetBCDE_mode_tag 1
#define HiToLo_enable_tag 6
#define HiToLo_disable_tag 7
#define HiToLo_keep_alive_tag 13
#define HiToLo_firmware_update_tag 16
#define HiToLo_allow_power_on_tag 21
#define HiToLo_reset_tag 23
#define HiToLo_set_bcde_tag 25
/* Struct field encoding specification for nanopb */
#define HiToLo_FIELDLIST(X, a) \
X(a, STATIC, ONEOF, MESSAGE, (payload,enable,payload.enable), 6) \
X(a, STATIC, ONEOF, MESSAGE, (payload,disable,payload.disable), 7) \
X(a, STATIC, ONEOF, MESSAGE, (payload,keep_alive,payload.keep_alive), 13) \
X(a, STATIC, ONEOF, MESSAGE, (payload,firmware_update,payload.firmware_update), 16) \
X(a, STATIC, ONEOF, MESSAGE, (payload,allow_power_on,payload.allow_power_on), 21) \
X(a, STATIC, ONEOF, MESSAGE, (payload,reset,payload.reset), 23) \
X(a, STATIC, ONEOF, MESSAGE, (payload,set_bcde,payload.set_bcde), 25)
#define HiToLo_CALLBACK NULL
#define HiToLo_DEFAULT NULL
#define HiToLo_payload_enable_MSGTYPE Enable
#define HiToLo_payload_disable_MSGTYPE Disable
#define HiToLo_payload_keep_alive_MSGTYPE KeepAliveHi
#define HiToLo_payload_firmware_update_MSGTYPE FirmwareUpdate
#define HiToLo_payload_allow_power_on_MSGTYPE AllowPowerOn
#define HiToLo_payload_reset_MSGTYPE Reset
#define HiToLo_payload_set_bcde_MSGTYPE SetBCDE
#define AllowPowerOn_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, p, 1)
#define AllowPowerOn_CALLBACK NULL
#define AllowPowerOn_DEFAULT NULL
#define SetBCDE_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, INT32, mode, 1)
#define SetBCDE_CALLBACK NULL
#define SetBCDE_DEFAULT NULL
#define FirmwareUpdate_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, invoke_rom_bootloader, 1)
#define FirmwareUpdate_CALLBACK NULL
#define FirmwareUpdate_DEFAULT NULL
#define KeepAliveHi_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, time_stamp, 1) \
X(a, STATIC, SINGULAR, UINT32, hw_type, 2) \
X(a, STATIC, SINGULAR, UINT32, hw_revision, 3) \
X(a, STATIC, SINGULAR, UINT32, protocol_version_major, 4) \
X(a, STATIC, SINGULAR, UINT32, protocol_version_minor, 5) \
X(a, STATIC, SINGULAR, STRING, sw_version_string, 6)
#define KeepAliveHi_CALLBACK NULL
#define KeepAliveHi_DEFAULT NULL
#define Enable_FIELDLIST(X, a) \
#define Enable_CALLBACK NULL
#define Enable_DEFAULT NULL
#define Disable_FIELDLIST(X, a) \
#define Disable_CALLBACK NULL
#define Disable_DEFAULT NULL
#define Reset_FIELDLIST(X, a) \
#define Reset_CALLBACK NULL
#define Reset_DEFAULT NULL
extern const pb_msgdesc_t HiToLo_msg;
extern const pb_msgdesc_t AllowPowerOn_msg;
extern const pb_msgdesc_t SetBCDE_msg;
extern const pb_msgdesc_t FirmwareUpdate_msg;
extern const pb_msgdesc_t KeepAliveHi_msg;
extern const pb_msgdesc_t Enable_msg;
extern const pb_msgdesc_t Disable_msg;
extern const pb_msgdesc_t Reset_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define HiToLo_fields &HiToLo_msg
#define AllowPowerOn_fields &AllowPowerOn_msg
#define SetBCDE_fields &SetBCDE_msg
#define FirmwareUpdate_fields &FirmwareUpdate_msg
#define KeepAliveHi_fields &KeepAliveHi_msg
#define Enable_fields &Enable_msg
#define Disable_fields &Disable_msg
#define Reset_fields &Reset_msg
/* Maximum encoded size of messages (where known) */
#define AllowPowerOn_size 2
#define Disable_size 0
#define Enable_size 0
#define FirmwareUpdate_size 2
#define HiToLo_size 84
#define KeepAliveHi_size 82
#define Reset_size 0
#define SetBCDE_size 11
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@@ -0,0 +1,46 @@
syntax = "proto3";
/*
This container message is send from Hi Level to Low level and may contain any allowed message in that direction.
*/
message HiToLo {
oneof payload {
// Common/configuration messages
Enable enable = 6;
Disable disable = 7;
KeepAliveHi keep_alive = 13;
FirmwareUpdate firmware_update = 16;
// Commands only available in control_mode = 2 (direct low level control)
SetBCDE set_bcde = 25;
AllowPowerOn allow_power_on = 21;
// Commands for HIL simulator
Reset reset = 23;
}
}
message AllowPowerOn {
bool p = 1;
}
message SetBCDE {
int32 mode = 1; // 0: A, 1: B, 2: C, 3: D, 4: E
}
message FirmwareUpdate {
bool invoke_rom_bootloader = 1;
}
message KeepAliveHi {
uint32 time_stamp = 1;
uint32 hw_type = 2;
uint32 hw_revision = 3;
uint32 protocol_version_major = 4;
uint32 protocol_version_minor = 5;
string sw_version_string = 6;
}
message Enable { }
message Disable { }
message Reset { }

View File

@@ -0,0 +1 @@
KeepAliveLo.sw_version_string max_length:50

View File

@@ -0,0 +1,25 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.4.6 */
#include "lo2hi.pb.h"
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
PB_BIND(LoToHi, LoToHi, AUTO)
PB_BIND(Event, Event, AUTO)
PB_BIND(Measurements, Measurements, AUTO)
PB_BIND(KeepAliveLo, KeepAliveLo, AUTO)
PB_BIND(ResetDone, ResetDone, AUTO)

View File

@@ -0,0 +1,189 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.4.6 */
#ifndef PB_LO2HI_PB_H_INCLUDED
#define PB_LO2HI_PB_H_INCLUDED
#include <everest/3rd_party/nanopb/pb.h>
#if PB_PROTO_HEADER_VERSION != 40
#error Regenerate this file with the current version of nanopb generator.
#endif
/* Enum definitions */
typedef enum _Event_InterfaceEvent {
Event_InterfaceEvent_A = 0,
Event_InterfaceEvent_B = 1,
Event_InterfaceEvent_C = 2,
Event_InterfaceEvent_D = 3,
Event_InterfaceEvent_E = 4,
Event_InterfaceEvent_F = 5,
Event_InterfaceEvent_EF = 6,
Event_InterfaceEvent_DISCONNECTED = 8,
Event_InterfaceEvent_ERROR_RELAIS = 9,
Event_InterfaceEvent_RELAIS_ON = 10,
Event_InterfaceEvent_RELAIS_OFF = 11
} Event_InterfaceEvent;
/* Struct definitions */
typedef struct _ResetDone {
char dummy_field;
} ResetDone;
typedef struct _Event {
Event_InterfaceEvent type;
} Event;
typedef struct _KeepAliveLo {
uint32_t time_stamp;
uint32_t hw_type;
uint32_t hw_revision;
uint32_t protocol_version_major;
uint32_t protocol_version_minor;
char sw_version_string[51];
float hwcap_max_current;
float hwcap_min_current;
uint32_t hwcap_max_phase_count;
uint32_t hwcap_min_phase_count;
bool supports_changing_phases_during_charging;
} KeepAliveLo;
typedef struct _Measurements {
float pwmDutyCycle;
float evse_pwm_voltage_hi;
float evse_pwm_voltage_lo;
bool evse_pwm_running;
uint32_t relais_on;
} Measurements;
/* This container message is send from Lo Level to Hi level and may contain any allowed message in that direction. */
typedef struct _LoToHi {
pb_size_t which_payload;
union {
/* Common Packets */
KeepAliveLo keep_alive;
/* HIL packets */
Measurements measurements;
/* Packets only available in control_mode = 2 (low level control) */
Event event;
ResetDone reset_done;
} payload;
} LoToHi;
/* Helper constants for enums */
#define _Event_InterfaceEvent_MIN Event_InterfaceEvent_A
#define _Event_InterfaceEvent_MAX Event_InterfaceEvent_RELAIS_OFF
#define _Event_InterfaceEvent_ARRAYSIZE ((Event_InterfaceEvent)(Event_InterfaceEvent_RELAIS_OFF+1))
#ifdef __cplusplus
extern "C" {
#endif
/* Initializer values for message structs */
#define LoToHi_init_default {0, {KeepAliveLo_init_default}}
#define Event_init_default {_Event_InterfaceEvent_MIN}
#define Measurements_init_default {0, 0, 0, 0, 0}
#define KeepAliveLo_init_default {0, 0, 0, 0, 0, "", 0, 0, 0, 0, 0}
#define ResetDone_init_default {0}
#define LoToHi_init_zero {0, {KeepAliveLo_init_zero}}
#define Event_init_zero {_Event_InterfaceEvent_MIN}
#define Measurements_init_zero {0, 0, 0, 0, 0}
#define KeepAliveLo_init_zero {0, 0, 0, 0, 0, "", 0, 0, 0, 0, 0}
#define ResetDone_init_zero {0}
/* Field tags (for use in manual encoding/decoding) */
#define Event_type_tag 1
#define KeepAliveLo_time_stamp_tag 1
#define KeepAliveLo_hw_type_tag 2
#define KeepAliveLo_hw_revision_tag 3
#define KeepAliveLo_protocol_version_major_tag 4
#define KeepAliveLo_protocol_version_minor_tag 5
#define KeepAliveLo_sw_version_string_tag 6
#define KeepAliveLo_hwcap_max_current_tag 7
#define KeepAliveLo_hwcap_min_current_tag 8
#define KeepAliveLo_hwcap_max_phase_count_tag 9
#define KeepAliveLo_hwcap_min_phase_count_tag 10
#define KeepAliveLo_supports_changing_phases_during_charging_tag 11
#define Measurements_pwmDutyCycle_tag 1
#define Measurements_evse_pwm_voltage_hi_tag 2
#define Measurements_evse_pwm_voltage_lo_tag 3
#define Measurements_evse_pwm_running_tag 4
#define Measurements_relais_on_tag 5
#define LoToHi_keep_alive_tag 3
#define LoToHi_measurements_tag 5
#define LoToHi_event_tag 6
#define LoToHi_reset_done_tag 7
/* Struct field encoding specification for nanopb */
#define LoToHi_FIELDLIST(X, a) \
X(a, STATIC, ONEOF, MESSAGE, (payload,keep_alive,payload.keep_alive), 3) \
X(a, STATIC, ONEOF, MESSAGE, (payload,measurements,payload.measurements), 5) \
X(a, STATIC, ONEOF, MESSAGE, (payload,event,payload.event), 6) \
X(a, STATIC, ONEOF, MESSAGE, (payload,reset_done,payload.reset_done), 7)
#define LoToHi_CALLBACK NULL
#define LoToHi_DEFAULT NULL
#define LoToHi_payload_keep_alive_MSGTYPE KeepAliveLo
#define LoToHi_payload_measurements_MSGTYPE Measurements
#define LoToHi_payload_event_MSGTYPE Event
#define LoToHi_payload_reset_done_MSGTYPE ResetDone
#define Event_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UENUM, type, 1)
#define Event_CALLBACK NULL
#define Event_DEFAULT NULL
#define Measurements_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FLOAT, pwmDutyCycle, 1) \
X(a, STATIC, SINGULAR, FLOAT, evse_pwm_voltage_hi, 2) \
X(a, STATIC, SINGULAR, FLOAT, evse_pwm_voltage_lo, 3) \
X(a, STATIC, SINGULAR, BOOL, evse_pwm_running, 4) \
X(a, STATIC, SINGULAR, UINT32, relais_on, 5)
#define Measurements_CALLBACK NULL
#define Measurements_DEFAULT NULL
#define KeepAliveLo_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, time_stamp, 1) \
X(a, STATIC, SINGULAR, UINT32, hw_type, 2) \
X(a, STATIC, SINGULAR, UINT32, hw_revision, 3) \
X(a, STATIC, SINGULAR, UINT32, protocol_version_major, 4) \
X(a, STATIC, SINGULAR, UINT32, protocol_version_minor, 5) \
X(a, STATIC, SINGULAR, STRING, sw_version_string, 6) \
X(a, STATIC, SINGULAR, FLOAT, hwcap_max_current, 7) \
X(a, STATIC, SINGULAR, FLOAT, hwcap_min_current, 8) \
X(a, STATIC, SINGULAR, UINT32, hwcap_max_phase_count, 9) \
X(a, STATIC, SINGULAR, UINT32, hwcap_min_phase_count, 10) \
X(a, STATIC, SINGULAR, BOOL, supports_changing_phases_during_charging, 11)
#define KeepAliveLo_CALLBACK NULL
#define KeepAliveLo_DEFAULT NULL
#define ResetDone_FIELDLIST(X, a) \
#define ResetDone_CALLBACK NULL
#define ResetDone_DEFAULT NULL
extern const pb_msgdesc_t LoToHi_msg;
extern const pb_msgdesc_t Event_msg;
extern const pb_msgdesc_t Measurements_msg;
extern const pb_msgdesc_t KeepAliveLo_msg;
extern const pb_msgdesc_t ResetDone_msg;
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
#define LoToHi_fields &LoToHi_msg
#define Event_fields &Event_msg
#define Measurements_fields &Measurements_msg
#define KeepAliveLo_fields &KeepAliveLo_msg
#define ResetDone_fields &ResetDone_msg
/* Maximum encoded size of messages (where known) */
#define Event_size 2
#define KeepAliveLo_size 106
#define LoToHi_size 108
#define Measurements_size 23
#define ResetDone_size 0
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@@ -0,0 +1,58 @@
syntax = "proto3";
/*
This container message is send from Lo Level to Hi level and may contain any allowed message in that direction.
*/
message LoToHi {
oneof payload {
// Common Packets
KeepAliveLo keep_alive = 3;
ResetDone reset_done = 7;
// Packets only available in control_mode = 2 (low level control)
Event event = 6;
// HIL packets
Measurements measurements = 5;
}
}
message Event {
enum InterfaceEvent {
A = 0;
B = 1;
C = 2;
D = 3;
E = 4;
F = 5;
EF = 6;
DISCONNECTED = 8;
ERROR_RELAIS = 9;
RELAIS_ON = 10;
RELAIS_OFF = 11;
}
InterfaceEvent type = 1;
}
message Measurements {
float pwmDutyCycle = 1;
float evse_pwm_voltage_hi = 2;
float evse_pwm_voltage_lo = 3;
bool evse_pwm_running = 4;
uint32 relais_on = 5;
}
message KeepAliveLo {
uint32 time_stamp = 1;
uint32 hw_type = 2;
uint32 hw_revision = 3;
uint32 protocol_version_major = 4;
uint32 protocol_version_minor = 5;
string sw_version_string = 6;
float hwcap_max_current = 7;
float hwcap_min_current = 8;
uint32 hwcap_max_phase_count = 9;
uint32 hwcap_min_phase_count = 10;
bool supports_changing_phases_during_charging = 11;
}
message ResetDone {
}