Change IDN response string
This commit is contained in:
parent
891e71c71e
commit
15e856d45b
|
@ -8,11 +8,24 @@ PIDFILE=/var/run/puzzlefw_remotectl.pid
|
|||
# Redirect output to console.
|
||||
exec &> /dev/console
|
||||
|
||||
# Get MAC address without ':' separators.
|
||||
serialnr=$(tr -d : < /sys/class/net/eth0/address)
|
||||
# Read model and serial number from EEPROM.
|
||||
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.
|
||||
/opt/puzzlefw/bin/remotectl --serialnr $serialnr &
|
||||
/opt/puzzlefw/bin/remotectl --model "$model" --serialnr "$serialnr" &
|
||||
serverpid=$!
|
||||
|
||||
# Write PID file.
|
||||
|
|
|
@ -449,10 +449,6 @@ class ControlServer;
|
|||
class CommandHandler
|
||||
{
|
||||
public:
|
||||
// IDN response fields.
|
||||
static constexpr const char * IDN_MANUFACTURER = "Jigsaw";
|
||||
static constexpr const char * IDN_MODEL = "PuzzleFw";
|
||||
|
||||
// Configuration files.
|
||||
static constexpr const char * CFG_FILE_CALIBRATION =
|
||||
"/var/lib/puzzlefw/cfg/calibration.conf";
|
||||
|
@ -477,10 +473,12 @@ public:
|
|||
/** Constructor. */
|
||||
CommandHandler(asio::io_context& io,
|
||||
PuzzleFwDevice& device,
|
||||
const std::string& model_name,
|
||||
const std::string& serial_number)
|
||||
: m_io(io)
|
||||
, m_strand(asio::make_strand(io))
|
||||
, m_device(device)
|
||||
, m_model_name(model_name)
|
||||
, m_serial_number(serial_number)
|
||||
, m_control_server(nullptr)
|
||||
, m_shutting_down(false)
|
||||
|
@ -732,9 +730,8 @@ private:
|
|||
std::string qry_idn(CommandEnvironment env)
|
||||
{
|
||||
VersionInfo fw_version = m_device.get_version_info();
|
||||
return str_format("%s,%s,%s,FW-%d.%d/SW-%d.%d",
|
||||
IDN_MANUFACTURER,
|
||||
IDN_MODEL,
|
||||
return str_format("RedPitaya,%s,%s,PuzzleFW-%d.%d/SW-%d.%d",
|
||||
m_model_name.c_str(),
|
||||
m_serial_number.c_str(),
|
||||
fw_version.major_version,
|
||||
fw_version.minor_version,
|
||||
|
@ -1419,6 +1416,7 @@ private:
|
|||
asio::io_context& m_io;
|
||||
asio::strand<asio::io_context::executor_type> m_strand;
|
||||
PuzzleFwDevice& m_device;
|
||||
std::string m_model_name;
|
||||
std::string m_serial_number;
|
||||
ControlServer* m_control_server;
|
||||
std::vector<DataServer*> m_data_servers;
|
||||
|
@ -1813,6 +1811,7 @@ void CommandHandler::start_data_servers(unsigned int idx)
|
|||
/** Run remote control server. */
|
||||
int run_remote_control_server(
|
||||
puzzlefw::PuzzleFwDevice& device,
|
||||
const std::string& model_name,
|
||||
const std::string& serial_number)
|
||||
{
|
||||
namespace asio = boost::asio;
|
||||
|
@ -1858,7 +1857,7 @@ int run_remote_control_server(
|
|||
device,
|
||||
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);
|
||||
|
||||
command_handler.set_control_server(control_server);
|
||||
|
@ -1901,14 +1900,17 @@ int run_remote_control_server(
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
enum Option { OPT_MODEL = 1, OPT_SERIALNR = 2 };
|
||||
static const struct option options[] = {
|
||||
{"help", 0, 0, 'h'},
|
||||
{"serialnr", 1, 0, 1 },
|
||||
{"model", 1, 0, OPT_MODEL },
|
||||
{"serialnr", 1, 0, OPT_SERIALNR },
|
||||
{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";
|
||||
|
||||
while (1) {
|
||||
|
@ -1921,7 +1923,10 @@ int main(int argc, char **argv)
|
|||
case 'h':
|
||||
printf(usage_text, argv[0]);
|
||||
return 0;
|
||||
case 1:
|
||||
case OPT_MODEL:
|
||||
model_name = optarg;
|
||||
break;
|
||||
case OPT_SERIALNR:
|
||||
serial_number = optarg;
|
||||
break;
|
||||
default:
|
||||
|
@ -1947,7 +1952,7 @@ int main(int argc, char **argv)
|
|||
printf(" DMA buffer size: %zu bytes\n",
|
||||
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) {
|
||||
fprintf(stderr, "ERROR: %s\n", e.what());
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#define PUZZLEFW_SW_MAJOR 0
|
||||
#define PUZZLEFW_SW_MINOR 2
|
||||
#define PUZZLEFW_SW_MINOR 3
|
||||
|
|
Loading…
Reference in New Issue