kopia lustrzana https://github.com/weetmuts/wmbusmeters
Partially removed reopenafter.
rodzic
de24888b4e
commit
8568437635
10
src/main.cc
10
src/main.cc
|
@ -217,10 +217,6 @@ shared_ptr<WMBus> createWMBusDeviceFrom(Detected *detected, Configuration *confi
|
|||
break;
|
||||
case DEVICE_RFMRX2:
|
||||
verbose("(rfmrx2) on %s\n", detected->device.file.c_str());
|
||||
if (config->reopenafter == 0)
|
||||
{
|
||||
manager->setReopenAfter(600); // Close and reopen the fd, because of some bug in the device.
|
||||
}
|
||||
wmbus = openRawTTY(detected->device.file, 38400, manager, serial_override);
|
||||
break;
|
||||
case DEVICE_RTLWMBUS:
|
||||
|
@ -727,10 +723,6 @@ void logStartInformation(Configuration *config)
|
|||
verbose("(config) wmbusmeters will exit after %d seconds\n", config->exitafter);
|
||||
}
|
||||
|
||||
if (config->reopenafter != 0) {
|
||||
verbose("(config) wmbusmeters close/open the wmbus dongle fd after every %d seconds\n", config->reopenafter);
|
||||
}
|
||||
|
||||
if (config->meterfiles) {
|
||||
verbose("(config) store meter files in: \"%s\"\n", config->meterfiles_dir.c_str());
|
||||
}
|
||||
|
@ -785,7 +777,7 @@ bool start(Configuration *config)
|
|||
logStartInformation(config);
|
||||
|
||||
// Create the manager monitoring all filedescriptors and invoking callbacks.
|
||||
serial_manager_ = createSerialCommunicationManager(config->exitafter, config->reopenafter);
|
||||
serial_manager_ = createSerialCommunicationManager(config->exitafter, true);
|
||||
// If our software unexpectedly exits, then stop the manager, to try
|
||||
// to achive a nice shutdown.
|
||||
onExit(call(serial_manager_.get(),stop));
|
||||
|
|
|
@ -67,7 +67,7 @@ struct Timer
|
|||
|
||||
struct SerialCommunicationManagerImp : public SerialCommunicationManager
|
||||
{
|
||||
SerialCommunicationManagerImp(time_t exit_after_seconds, time_t reopen_after_seconds, bool start_event_loop);
|
||||
SerialCommunicationManagerImp(time_t exit_after_seconds, bool start_event_loop);
|
||||
~SerialCommunicationManagerImp();
|
||||
|
||||
shared_ptr<SerialDevice> createSerialDeviceTTY(string dev, int baud_rate);
|
||||
|
@ -331,6 +331,7 @@ void SerialDeviceTTY::close()
|
|||
|
||||
void SerialDeviceTTY::checkIfShouldReopen()
|
||||
{
|
||||
assert(0);
|
||||
if (fd_ != -1 && reopen_after_ > 0)
|
||||
{
|
||||
time_t curr = time(NULL);
|
||||
|
@ -354,19 +355,6 @@ void SerialDeviceTTY::checkIfShouldReopen()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void SerialDeviceTTY::forceReopen()
|
||||
{
|
||||
debug("(serialtty) forced reopen and reset!\n", diff);
|
||||
::flock(fd_, LOCK_UN);
|
||||
::close(fd_);
|
||||
fd_ = openSerialTTY(device_.c_str(), baud_rate_);
|
||||
if (fd_ == -1)
|
||||
{
|
||||
error("Could not re-open %s with %d baud N81\n", device_.c_str(), baud_rate_);
|
||||
}
|
||||
}
|
||||
*/
|
||||
bool SerialDeviceTTY::send(vector<uchar> &data)
|
||||
{
|
||||
LOCK_WRITE_SERIAL(send);
|
||||
|
@ -676,7 +664,6 @@ struct SerialDeviceSimulator : public SerialDeviceImp
|
|||
};
|
||||
|
||||
SerialCommunicationManagerImp::SerialCommunicationManagerImp(time_t exit_after_seconds,
|
||||
time_t reopen_after_seconds,
|
||||
bool start_event_loop)
|
||||
{
|
||||
running_ = true;
|
||||
|
@ -691,7 +678,7 @@ SerialCommunicationManagerImp::SerialCommunicationManagerImp(time_t exit_after_s
|
|||
wakeMeUpOnSigChld(getEventLoopThread());
|
||||
start_time_ = time(NULL);
|
||||
exit_after_seconds_ = exit_after_seconds;
|
||||
reopen_after_seconds_ = reopen_after_seconds;
|
||||
reopen_after_seconds_ = 0;
|
||||
}
|
||||
|
||||
shared_ptr<SerialDevice> SerialCommunicationManagerImp::createSerialDeviceTTY(string device,
|
||||
|
@ -936,15 +923,6 @@ void *SerialCommunicationManagerImp::timerLoop()
|
|||
}
|
||||
|
||||
executeTimerCallbacks();
|
||||
|
||||
{
|
||||
LOCK_SERIAL_DEVICES(check_for_reopens);
|
||||
|
||||
for (shared_ptr<SerialDevice> &sd : serial_devices_)
|
||||
{
|
||||
sd->checkIfShouldReopen();
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1070,11 +1048,9 @@ void *SerialCommunicationManagerImp::eventLoop()
|
|||
}
|
||||
|
||||
shared_ptr<SerialCommunicationManager> createSerialCommunicationManager(time_t exit_after_seconds,
|
||||
time_t reopen_after_seconds,
|
||||
bool start_event_loop)
|
||||
{
|
||||
return shared_ptr<SerialCommunicationManager>(new SerialCommunicationManagerImp(exit_after_seconds,
|
||||
reopen_after_seconds,
|
||||
start_event_loop));
|
||||
}
|
||||
|
||||
|
|
|
@ -106,8 +106,7 @@ struct SerialCommunicationManager
|
|||
virtual ~SerialCommunicationManager();
|
||||
};
|
||||
|
||||
shared_ptr<SerialCommunicationManager> createSerialCommunicationManager(time_t exit_after_seconds = 0,
|
||||
time_t reopen_after_seconds = 0,
|
||||
bool start_event_loop = true);
|
||||
shared_ptr<SerialCommunicationManager> createSerialCommunicationManager(time_t exit_after_seconds,
|
||||
bool start_event_loop);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -215,7 +215,7 @@ int test_dvparser()
|
|||
|
||||
int test_test()
|
||||
{
|
||||
shared_ptr<SerialCommunicationManager> manager = createSerialCommunicationManager(0, 0, false);
|
||||
shared_ptr<SerialCommunicationManager> manager = createSerialCommunicationManager(0, false);
|
||||
|
||||
shared_ptr<SerialDevice> serial1 = manager->createSerialDeviceSimulator();
|
||||
|
||||
|
@ -228,7 +228,7 @@ int test_test()
|
|||
int test_linkmodes()
|
||||
{
|
||||
LinkModeCalculationResult lmcr;
|
||||
auto manager = createSerialCommunicationManager(0, 0, false);
|
||||
auto manager = createSerialCommunicationManager(0, false);
|
||||
|
||||
auto serial1 = manager->createSerialDeviceSimulator();
|
||||
auto serial2 = manager->createSerialDeviceSimulator();
|
||||
|
|
|
@ -3,4 +3,3 @@ device=simulations/simulation_conversionsadded.txt
|
|||
logtelegrams=false
|
||||
format=json
|
||||
addconversions=GJ,L,F
|
||||
reopenafter=1h
|
|
@ -65,8 +65,6 @@ mqtt_publish) sent to a REST API (eg curl) or store it in a database
|
|||
|
||||
\fB\--oneshot\fR wait for an update from each meter, then quit
|
||||
|
||||
\fB\--reopenafter=\fR<time> close/reopen dongle connection repeatedly every <time> seconds, eg 60s, 60m, 24h
|
||||
|
||||
\fB\--separator=\fR<c> change field separator to c
|
||||
|
||||
\fB\--selectfields=\fRid,timestamp,total_m3 select fields to be printed (--listfields=<meter> to list available fields)
|
||||
|
|
Ładowanie…
Reference in New Issue