Change IDN response string

This commit is contained in:
Joris van Rantwijk 2024-10-04 13:12:11 +02:00
parent 891e71c71e
commit 15e856d45b
3 changed files with 34 additions and 16 deletions

View File

@ -8,11 +8,24 @@ PIDFILE=/var/run/puzzlefw_remotectl.pid
# Redirect output to console. # Redirect output to console.
exec &> /dev/console exec &> /dev/console
# Get MAC address without ':' separators. # Read model and serial number from EEPROM.
serialnr=$(tr -d : < /sys/class/net/eth0/address) model=unknown
serialnr=0
dd if=/sys/bus/i2c/devices/0-0050/eeprom bs=1k skip=6 count=1 status=none | tr '\000' '\n' > /tmp/run_remotectl_eeprom
while read -r cfgitem cfgrest ; do
if [ "$cfgitem" != "${cfgitem#hw_rev=}" ]; then
model="${cfgitem#hw_rev=}"
fi
if [ "$cfgitem" != "${cfgitem#ethaddr=}" ]; then
serialnr="${cfgitem#ethaddr=}"
fi
done < /tmp/run_remotectl_eeprom
echo "model=$model"
echo "serialnr=$serialnr"
# Run remote control server. # Run remote control server.
/opt/puzzlefw/bin/remotectl --serialnr $serialnr & /opt/puzzlefw/bin/remotectl --model "$model" --serialnr "$serialnr" &
serverpid=$! serverpid=$!
# Write PID file. # Write PID file.

View File

@ -449,10 +449,6 @@ class ControlServer;
class CommandHandler class CommandHandler
{ {
public: public:
// IDN response fields.
static constexpr const char * IDN_MANUFACTURER = "Jigsaw";
static constexpr const char * IDN_MODEL = "PuzzleFw";
// Configuration files. // Configuration files.
static constexpr const char * CFG_FILE_CALIBRATION = static constexpr const char * CFG_FILE_CALIBRATION =
"/var/lib/puzzlefw/cfg/calibration.conf"; "/var/lib/puzzlefw/cfg/calibration.conf";
@ -477,10 +473,12 @@ public:
/** Constructor. */ /** Constructor. */
CommandHandler(asio::io_context& io, CommandHandler(asio::io_context& io,
PuzzleFwDevice& device, PuzzleFwDevice& device,
const std::string& model_name,
const std::string& serial_number) const std::string& serial_number)
: m_io(io) : m_io(io)
, m_strand(asio::make_strand(io)) , m_strand(asio::make_strand(io))
, m_device(device) , m_device(device)
, m_model_name(model_name)
, m_serial_number(serial_number) , m_serial_number(serial_number)
, m_control_server(nullptr) , m_control_server(nullptr)
, m_shutting_down(false) , m_shutting_down(false)
@ -732,9 +730,8 @@ private:
std::string qry_idn(CommandEnvironment env) std::string qry_idn(CommandEnvironment env)
{ {
VersionInfo fw_version = m_device.get_version_info(); VersionInfo fw_version = m_device.get_version_info();
return str_format("%s,%s,%s,FW-%d.%d/SW-%d.%d", return str_format("RedPitaya,%s,%s,PuzzleFW-%d.%d/SW-%d.%d",
IDN_MANUFACTURER, m_model_name.c_str(),
IDN_MODEL,
m_serial_number.c_str(), m_serial_number.c_str(),
fw_version.major_version, fw_version.major_version,
fw_version.minor_version, fw_version.minor_version,
@ -1419,6 +1416,7 @@ private:
asio::io_context& m_io; asio::io_context& m_io;
asio::strand<asio::io_context::executor_type> m_strand; asio::strand<asio::io_context::executor_type> m_strand;
PuzzleFwDevice& m_device; PuzzleFwDevice& m_device;
std::string m_model_name;
std::string m_serial_number; std::string m_serial_number;
ControlServer* m_control_server; ControlServer* m_control_server;
std::vector<DataServer*> m_data_servers; std::vector<DataServer*> m_data_servers;
@ -1813,6 +1811,7 @@ void CommandHandler::start_data_servers(unsigned int idx)
/** Run remote control server. */ /** Run remote control server. */
int run_remote_control_server( int run_remote_control_server(
puzzlefw::PuzzleFwDevice& device, puzzlefw::PuzzleFwDevice& device,
const std::string& model_name,
const std::string& serial_number) const std::string& serial_number)
{ {
namespace asio = boost::asio; namespace asio = boost::asio;
@ -1858,7 +1857,7 @@ int run_remote_control_server(
device, device,
std::chrono::milliseconds(100)); std::chrono::milliseconds(100));
CommandHandler command_handler(io, device, serial_number); CommandHandler command_handler(io, device, model_name, serial_number);
ControlServer control_server(io, command_handler, 5025); ControlServer control_server(io, command_handler, 5025);
command_handler.set_control_server(control_server); command_handler.set_control_server(control_server);
@ -1901,14 +1900,17 @@ int run_remote_control_server(
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
enum Option { OPT_MODEL = 1, OPT_SERIALNR = 2 };
static const struct option options[] = { static const struct option options[] = {
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"serialnr", 1, 0, 1 }, {"model", 1, 0, OPT_MODEL },
{"serialnr", 1, 0, OPT_SERIALNR },
{nullptr, 0, 0, 0} {nullptr, 0, 0, 0}
}; };
const char *usage_text = "Usage: %s --serialnr SNR\n"; const char *usage_text = "Usage: %s --model MODEL --serialnr SNR\n";
std::string model_name = "unknown";
std::string serial_number = "0"; std::string serial_number = "0";
while (1) { while (1) {
@ -1921,7 +1923,10 @@ int main(int argc, char **argv)
case 'h': case 'h':
printf(usage_text, argv[0]); printf(usage_text, argv[0]);
return 0; return 0;
case 1: case OPT_MODEL:
model_name = optarg;
break;
case OPT_SERIALNR:
serial_number = optarg; serial_number = optarg;
break; break;
default: default:
@ -1947,7 +1952,7 @@ int main(int argc, char **argv)
printf(" DMA buffer size: %zu bytes\n", printf(" DMA buffer size: %zu bytes\n",
device.dma_buffer_size()); device.dma_buffer_size());
return run_remote_control_server(device, serial_number); return run_remote_control_server(device, model_name, serial_number);
} catch (std::exception& e) { } catch (std::exception& e) {
fprintf(stderr, "ERROR: %s\n", e.what()); fprintf(stderr, "ERROR: %s\n", e.what());

View File

@ -1,2 +1,2 @@
#define PUZZLEFW_SW_MAJOR 0 #define PUZZLEFW_SW_MAJOR 0
#define PUZZLEFW_SW_MINOR 2 #define PUZZLEFW_SW_MINOR 3