Skip to content

Commit

Permalink
Merge pull request wmbusmeters#513 from bb-froggy/debug/cuno
Browse files Browse the repository at this point in the history
Allow CMD for CUL device
  • Loading branch information
weetmuts authored May 25, 2022
2 parents 5149e15 + c4271bc commit b221401
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/wmbus_cul.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,29 @@ struct WMBusCUL : public virtual WMBusCommonImplementation
shared_ptr<WMBus> openCUL(Detected detected, shared_ptr<SerialCommunicationManager> manager, shared_ptr<SerialDevice> serial_override)
{
string bus_alias = detected.specified_device.bus_alias;
string device = detected.found_file;
if (serial_override)
{
WMBusCUL *imp = new WMBusCUL(bus_alias, serial_override, manager);
imp->markAsNoLongerSerial();
return shared_ptr<WMBus>(imp);
}

auto serial = manager->createSerialDeviceTTY(device.c_str(), 38400, PARITY::NONE, "cul");
if (detected.specified_device.command != "")
{
string identifier = "cmd_" + to_string(detected.specified_device.index);

vector<string> args;
vector<string> envs;
args.push_back("-c");
args.push_back(detected.specified_device.command);

auto serial = manager->createSerialDeviceCommand(identifier, "/bin/sh", args, envs, "cul");
WMBusCUL *imp = new WMBusCUL(bus_alias, serial, manager);
return shared_ptr<WMBus>(imp);
}

string device = detected.found_file;
auto serial = manager->createSerialDeviceTTY(device.c_str(), 38400, PARITY::NONE, "cul");
WMBusCUL *imp = new WMBusCUL(bus_alias, serial, manager);
return shared_ptr<WMBus>(imp);
}
Expand Down

0 comments on commit b221401

Please sign in to comment.