I just tried it on my PC and it seems to work. Probably the difference is due to differences in libc++ implementations. Are you seeing this error while running linknx on your desktop PC or is it on an embedded platform? What libc++ are you using libstdc++ or uclibc++, and which version are you using (you can locate the lib you are using with the command "ldd linknx" and then follow the symlinkx to know which version it's pointing to). I remember I had some problems with uClibc++ at the beginning, but everything works fine since I upgarded to uClibc++ version 2.2 . I'll try to configure persistence with EIS5 objects on my WRT54GS today and see if it makes a difference.
Kr,
Jean-François
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't understand why you are using persistent object for actual temperature values. In my opinion, it's not useful to save it because you can always ask this temperature to the sensor.
Additionnaly, if the persistence directory is located on a compactflash, writing it so frequently could shorten the life of the flash device.
Kind regards,
Jean-François
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This doesn't explain why you are using init="persist" for an object representing a measurement value. In my opinion, it makes no sense to do this, but perhaps I missed something.
For the moment, there's no logging function in linknx. One of the patches I added to eibd provides the "knxlog" command that allows me to log all the group telegrams on the bus. Once in a while, I backup these logs on the PC and have a couple of perl scripts to parse it and extract the information I want, or draw some temperature graphs. It could be interesting to have logging functionality in linknx. Any idea on how it should work is welcome.
Kr,
Jean-François
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
+ logValue_m = pConfig->GetAttribute("log");
+
// TODO: do we need to use the 'i' flag instead of init="request" attribute
initValue_m = pConfig->GetAttribute("init");
if (initValue_m == "persist")
@@ -184,6 +186,9 @@
if (initValue_m != "")
pConfig->SetAttribute("init", initValue_m);
+
+ if (logValue_m != "")
+ pConfig->SetAttribute("log", logValue_m);
if (flags_m != Default)
{
@@ -251,6 +256,13 @@
PersistentStorage *persistence = Services::instance()->getPersistentStorage();
if (persistence)
persistence->write(id_m, getValue());
+ }
+
+ if (logValue_m == "true")
+ {
+ PersistentStorage *persistence = Services::instance()->getPersistentStorage();
+ if (persistence)
+ persistence->writelog(id_m, getValue());
}
}
The logging functionality is relased in linknx-0.0.1.22
I changed a little bit the format of the logfile to stay consistant with date and time formatting in other parts of linknx, and added a ">" sign between timestamp and value to make it easier to parse by other applications.
I also added a second parameter "logpath" to allow user to separate logs from persistence if needed. E.g.:
<persistence type="file" path="/var/lib/linknx/persist" logpath="/tmp/linknx/logs"/>
Kr,
Jean-François
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
if I try init="persist" on a EIS5 object, the
answer is:
PersistentStorage: reading '19.29' for object 'Ist'
ValueObjectValue: Bad value: '19.29'
please help me
regards matthias
Hi,
I just tried it on my PC and it seems to work. Probably the difference is due to differences in libc++ implementations. Are you seeing this error while running linknx on your desktop PC or is it on an embedded platform? What libc++ are you using libstdc++ or uclibc++, and which version are you using (you can locate the lib you are using with the command "ldd linknx" and then follow the symlinkx to know which version it's pointing to). I remember I had some problems with uClibc++ at the beginning, but everything works fine since I upgarded to uClibc++ version 2.2 . I'll try to configure persistence with EIS5 objects on my WRT54GS today and see if it makes a difference.
Kr,
Jean-François
I reproduced the problem, but only on my WRT54GS. It's probably a problem with uClibc++ v0.2.2. I'll investigate it
Problem found in uClibc++. After execution of the following code, the "eof" flag of val should be set, but it's not the case.
float value_m;
std::istringstream val("19.29");
val >> value_m;
The fix is in CVS.
Target relase: 0.0.1.22
Now I need some sleep ;-)
Kind regards,
Jean-François
Hello Jean-François,
thank you. All works fine.
Matthias
Hi,
I don't understand why you are using persistent object for actual temperature values. In my opinion, it's not useful to save it because you can always ask this temperature to the sensor.
Additionnaly, if the persistence directory is located on a compactflash, writing it so frequently could shorten the life of the flash device.
Kind regards,
Jean-François
Hello Jean-François,
I found the error as I try to set the outer temperature
with knxwrite in my php-file.
Another theme:
Is it possible to log a GAD in a file to make statics or
record as a macro?
Best regards Matthias
Hi,
This doesn't explain why you are using init="persist" for an object representing a measurement value. In my opinion, it makes no sense to do this, but perhaps I missed something.
For the moment, there's no logging function in linknx. One of the patches I added to eibd provides the "knxlog" command that allows me to log all the group telegrams on the bus. Once in a while, I backup these logs on the PC and have a couple of perl scripts to parse it and extract the information I want, or draw some temperature graphs. It could be interesting to have logging functionality in linknx. Any idea on how it should work is welcome.
Kr,
Jean-François
Hello Jean-François,
here a try to log:
--- /root/workspace/linknx/linknx/src/objectcontroller.cpp
+++ /home/user/trunk/build_dir/mipsel/linknx-0.0.1.19/src/objectcontroller.cpp
@@ -149,6 +149,8 @@
flags_m |= Force;
// END: backward compatibility with 0.0.1.17
+ logValue_m = pConfig->GetAttribute("log");
+
// TODO: do we need to use the 'i' flag instead of init="request" attribute
initValue_m = pConfig->GetAttribute("init");
if (initValue_m == "persist")
@@ -184,6 +186,9 @@
if (initValue_m != "")
pConfig->SetAttribute("init", initValue_m);
+
+ if (logValue_m != "")
+ pConfig->SetAttribute("log", logValue_m);
if (flags_m != Default)
{
@@ -251,6 +256,13 @@
PersistentStorage *persistence = Services::instance()->getPersistentStorage();
if (persistence)
persistence->write(id_m, getValue());
+ }
+
+ if (logValue_m == "true")
+ {
+ PersistentStorage *persistence = Services::instance()->getPersistentStorage();
+ if (persistence)
+ persistence->writelog(id_m, getValue());
}
}
--- /root/workspace/linknx/linknx/src/objectcontroller.h
+++ /home/user/trunk/build_dir/mipsel/linknx-0.0.1.19/src/objectcontroller.h
@@ -97,6 +97,7 @@
eibaddr_t gad_m;
eibaddr_t lastTx_m;
std::string initValue_m;
+ std::string logValue_m;
bool readPending_m;
std::string descr_m;
typedef std::list<ChangeListener*> ListenerList_t;
--- /root/workspace/linknx/linknx/src/persistentstorage.cpp
+++ /home/user/trunk/build_dir/mipsel/linknx-0.0.1.19/src/persistentstorage.cpp
@@ -72,6 +72,21 @@
fp_out.close();
}
+void FilePersistentStorage::writelog(const std::string& id, const std::string& value)
+{
+ std::cout << "PersistentStorage: writing log'" << value << "' for object '" << id << "'" << std::endl;
+ std::string filename = path_m+id+".log";
+ std::ofstream fp_out(filename.c_str(), std::ios::app);
+
+ time_t tim = time(0);
+ struct tm * timeinfo = localtime(&tim);
+
+ fp_out << timeinfo->tm_year+1900 << ":" << timeinfo->tm_mon+1 << ":" << timeinfo->tm_mday << ":";
+ fp_out << timeinfo->tm_hour << ":" << timeinfo->tm_min << ":" << timeinfo->tm_sec;
+ fp_out << " " << value << "\n";
+ fp_out.close();
+}
+
std::string FilePersistentStorage::read(const std::string& id, const std::string& defval)
{
std::string value;
--- /root/workspace/linknx/linknx/src/persistentstorage.h
+++ /home/user/trunk/build_dir/mipsel/linknx-0.0.1.19/src/persistentstorage.h
@@ -33,6 +33,7 @@
virtual void exportXml(ticpp::Element* pConfig) = 0;
+ virtual void writelog(const std::string& id, const std::string& value) = 0;
virtual void write(const std::string& id, const std::string& value) = 0;
virtual std::string read(const std::string& id, const std::string& defval="") = 0;
};
@@ -45,6 +46,7 @@
virtual void exportXml(ticpp::Element* pConfig);
+ virtual void writelog(const std::string& id, const std::string& value);
virtual void write(const std::string& id, const std::string& value);
virtual std::string read(const std::string& id, const std::string& defval="");
private:
regards
Matthias
Thanks,
The logging functionality is relased in linknx-0.0.1.22
I changed a little bit the format of the logfile to stay consistant with date and time formatting in other parts of linknx, and added a ">" sign between timestamp and value to make it easier to parse by other applications.
I also added a second parameter "logpath" to allow user to separate logs from persistence if needed. E.g.:
<persistence type="file" path="/var/lib/linknx/persist" logpath="/tmp/linknx/logs"/>
Kr,
Jean-François
Hello,
there is a problem with the uclibc++
on openwrt, i think.
Your valueobject can`t get a negative
value.
regards
Matthias
Hi,
You're right, there's a bug in uClibc++. I submitted the following patch to uClibc++ author:
http://ouaye.net/linknx/other/uClibc++-istream-negative.patch
Kind regards,
Jean-François