{"id":2960,"date":"2017-12-11T19:24:54","date_gmt":"2017-12-11T19:24:54","guid":{"rendered":"http:\/\/grodansparadis.com\/wordpress\/?p=2960"},"modified":"2017-12-11T19:24:54","modified_gmt":"2017-12-11T19:24:54","slug":"vscp-howto-dm-write-append-to-file","status":"publish","type":"post","link":"https:\/\/grodansparadis.com\/wordpress\/?p=2960","title":{"rendered":"#VSCP HOWTO: DM write\/append to file"},"content":{"rendered":"<p><a href=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2648\" data-permalink=\"https:\/\/grodansparadis.com\/wordpress\/?attachment_id=2648\" data-orig-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?fit=1123%2C794&amp;ssl=1\" data-orig-size=\"1123,794\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"vscp_logo_short_box\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?fit=580%2C410&amp;ssl=1\" class=\"alignnone size-full wp-image-2648\" src=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?resize=580%2C410\" alt=\"\" width=\"580\" height=\"410\" srcset=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?w=1123&amp;ssl=1 1123w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?resize=300%2C212&amp;ssl=1 300w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?resize=768%2C543&amp;ssl=1 768w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/08\/vscp_logo_short_box.jpg?resize=1024%2C724&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=level1_driver_logger\">The Level I logger<\/a> and <a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=level2_driver_logger\">the Level II logger<\/a> are great tools for logging events in a VSCP based system.\u00a0 Useful also for debugging etc. Another method is to use the <a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#execute_external_program\">execute external program action<\/a> and execute a script and write to a file there. We have seen this method being used in other howtos.\u00a0 Also while running a JavaScript or a Lua script files can be written.<\/p>\n<p>But&#8230;<\/p>\n<p>file writing is also available as an action.\u00a0 It is documented <a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#write_to_file_plain\">here<\/a>. This action allows writing or appending a string with output to a named file that is created if it does not exist. With the <a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#variable_substitution_for_parameters_escapes\">VSCP escapes<\/a> a lot of dynamic information can go into this file.<\/p>\n<p>Suppose that we want to\u00a0 log events of a certain type to a file, here CLASS1.DATA, Type=2 A\/D values form a specific device. We then write a decision matrix (DM) row<\/p>\n<pre>&lt;row enable=\"true\" groupid=\"\" &gt;\r\n\r\n&lt;comment&gt;\r\n Collect A\/D values from node X\r\n&lt;\/comment&gt;\r\n\r\n&lt;mask priority=\"0\"\r\n class=\"0xFFFF\"\r\n type=\"0xFFFF\"\r\n GUID=\"FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF\" \/&gt;\r\n\r\n&lt;filter priority=\"0\"\r\n class=\"15\"\r\n type=\"2\"\r\n GUID=\"00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F\" \/&gt;\r\n\r\n&lt;action&gt;0x70&lt;\/action&gt;\r\n &lt;param&gt;\r\n \/tmp\/addata;1;%isoboth: %measurement.string %lf \r\n &lt;\/param&gt;\r\n\r\n&lt;\/row&gt;<\/pre>\n<p>will generate output content like this<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/Screenshot-from-2017-12-11-20-20-32.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"2961\" data-permalink=\"https:\/\/grodansparadis.com\/wordpress\/?attachment_id=2961\" data-orig-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/Screenshot-from-2017-12-11-20-20-32.png?fit=745%2C204&amp;ssl=1\" data-orig-size=\"745,204\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot from 2017-12-11 20-20-32\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/Screenshot-from-2017-12-11-20-20-32.png?fit=580%2C159&amp;ssl=1\" class=\"alignnone size-full wp-image-2961\" src=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/Screenshot-from-2017-12-11-20-20-32.png?resize=580%2C159\" alt=\"\" width=\"580\" height=\"159\" srcset=\"https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/Screenshot-from-2017-12-11-20-20-32.png?w=745&amp;ssl=1 745w, https:\/\/i0.wp.com\/grodansparadis.com\/wordpress\/wp-content\/uploads\/2017\/12\/Screenshot-from-2017-12-11-20-20-32.png?resize=300%2C82&amp;ssl=1 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p>With the other <a href=\"http:\/\/www.vscp.org\/docs\/vscpd\/doku.php?id=vscp_daemon_decision_matrix#variable_substitution_for_parameters_escapes\">VSCP escapes<\/a> and literals you have many options to generate meaningful output.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Level I logger and the Level II logger are great tools for logging events in a VSCP based system.\u00a0 Useful also for debugging etc. Another method is to use the execute external program action and execute a script and write to a file there. We have seen this method being used in other howtos.\u00a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[53,13],"tags":[],"class_list":["post-2960","post","type-post","status-publish","format-standard","hentry","category-howtos","category-vscp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4raCZ-LK","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2960"}],"version-history":[{"count":1,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2960\/revisions"}],"predecessor-version":[{"id":2962,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2960\/revisions\/2962"}],"wp:attachment":[{"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/grodansparadis.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}