Categories
General

Chrome is Turning Into the New Internet Explorer

“When the largest web company in the world blocks out competitors, it smells less like an accident and more like strategy,”

Slashdot opinion here

Categories
General

A development truth

Source

 

Categories
General

Good intro to Markdown

https://hackernoon.com/boost-your-productivity-using-markdown-b8a84fc2a089

Categories
General

Bra

Categories
General

The question is…

…if there is any idea to have a group like this active anymore… Probably not.

Categories
General HowTo's VSCP

#VSCP HOWTO: DM Using timers

Timers. One can wonder what they do in the decision matrix? They even have their own events defined in the CLASS2.VSCP class.

First let us define what a VSCP timer is.

A VSCP timer is a free running 32-bit timer with millisecond resolution.  That is they can hold  0xffffffff = 4294967295 milliseconds which mens they will roll over in about 50 days.

There are actions defined to

There is the following  internal events defined related to timers

To create and start a timer

<row enable="true" groupid="timers" >

  <comment>
    Create timer
  </comment>

  <mask priority="0"
        class="0xFFFF"
        type="0xFFFF"
 GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

  <filter priority="0"
          class="65535"
          type="23"
 GUID="00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F" />

  <action>0x60</action>
  <param>
    1;10;timer1flag;true
  </param>

</row>

Here a timer with id = 1 is created. The timer has an initial time set to 10 seconds. When this timer elapses it will set the variable //timer1flag// to true. The last argument is the reload flag. Here it is set to true so when the time has elapsed the initial value will be loaded again and the timer will start again.

In the example above we could have added “;4” at the end of the parameter which would have the effect that the reload would stop after four runs. Default is thus forever.

When the timer is started a CLASS2.VSCPD, Type = 25 (0x0019) Timer started event is generated. When the ten seconds has gone and the timer elapses the  CLASS2.VSCPD, Type = 29 (0x001D) Timer Elapsed event is generated.

We can use either one of these two generated events to do any action periodically like this.

<row enable="true" groupid="timers" >

  <comment> 
    Handle timer elapsed
  </comment>

  <mask priority="0"
        class="0xFFFF"
        type="0xFFFF"
 GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

  <filter priority="0"
          class="65535"
          type="29"
 GUID="00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F" />

  <action>0x70</action>
  <param>
    /srv/vscp/timefile;1;%isoboth: Timer with  id=%event.data.int32[0] elapsed %lf
  </param>

</row>


<row enable="true" groupid="timers" > 

   <comment> Handle timer elapsed </comment> 
   <mask priority="0" 
         class="0xFFFF" 
         type="0xFFFF" GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" /> 
    <filter priority="0" 
            class="65535" 
            type="25" GUID="00:01:02:03:04:05:06:07:08:09:0A:0B:0C:0D:0E:0F" /> 

    <action>0x70</action> 
    <param> 
      /srv/vscp/timefile;1;%isoboth: Timer with id=%event.data.int32[0] elapsed counter=%event.data.uint32[0]ms %lf </param> </row>

Here some info is just written to a file when the timer is started and when it elapses.   But if you want to send an event periodically instead or do other actions this is the way to do it.

You don’t have to give a variable nor a reload flag when you start a timer. If no variable is given (use ;;) it is just ignored. The reload value will be set to false as default  value, that is the timer will run only once. As the last parameter you can set the number of times the timer should reload before it should stop.  The full documentation is here and here.

One useful use of timers is to handle resend of events. The working is like this

Send the event you expect a reply event from another node.

  1. Create/start a timer that have  period equal to resend intervals for the event you want to send. The timer should  have true for autoloading and the number of autoloads set to the number of resend that are allowed.  You can trigger the creation of the timer  by make a DM entry that triggering on one of the reserved events for example,  CLASS1.LOCAL  or CLASS1.LABORATORY so that when you send this local event  the actual event will be sent (see next point)
  2. In the timer started event send  the event you want to send.
  3. When/If the expected reply  is received pause the timer.
  4. Now if the timer the timer stopped event is detected the reply wait timeout has expired so do timeout handling there by sending another local event or CLASS1.ERROR, Type = 32 Time out.

Can be used for much more of course. Just useful and simple.

Categories
General HowTo's VSCP

#VSCP HOWTO: DM Check measurement

In another Howto we looked at the measurement compares that are available in the decision matrix (DM) record (VSCP HOWTO: COMPARE VALUES WITHOUT CODING). Here we will look at an action that work in a similar equal manner.

The check measurement action

VSCP_DAEMON_ACTION_CODE_CHECK_MEASUREMENT

is defined to make it possible to check a measurement against a literal value and just as we described in the howto about the check variable actions it stores the logical outcome of the compare in a boolean remote variable.

Also here equal to, less than, greater than etc is available.  A typical parameter row can look like this

0;0;99.5;gt;flag

This says that if a measurement comes in that have a value that is greater than 99.5 the remote variable “flag” will be set to true. In all other cases “flag” will be set to “false”.  The “0;0” that is the first two values of the parameter line is  unit and sensor index. In this case the measurement therefore must have unit=0 and sensor index = 0 as well for the test to be evaluated at all.

A complete example is available in the documentation of the action. You can find pre written samples here.

As a note. Instead of a literal value for the compare you can use another variable.  The parameter above can be rewritten

0;0;%variable:[critical_value];gt;flag

and instead of the literal “99.5” the value of the remote variable 99.5 is used for the compare.  VSCP DM escapes are evaluated before an action is carried out. There is many of them and they can be very useful when you want to make decision matrix rows act in a more dynamic way without go so far as to use full JavaScript or Lua.  You can read more about the VSCP DM escapes here.

It isn’t harder than that actually.

Categories
General

Level III drivers… and HELP!!!! #VSCP

VSCP have Level I (CANAL) and  Level II drivers. Now there will maybe be Level III drivers to.  Drivers that can be written in any programming language.  Hmmmmm….

Another things is the installation of drivers on a remote machine. “Bundles” may the zip files be called (OSGi language).  Or something funnier maybe. But a way to install drivers/web content/UX data and other things on a remote VSCP system in a secure way. Hmmmm…

The tcp/ip interface should have mailboxes.  What is that you may ask. Or not… 😉   I will tell you anyway. A mailbox collect events for a client  that is not connected. When the client connects it can get the events from its mailbox, Neat for long time sleeping RF devices. Hmmmmmmmm… and hmmmmmmmm….. and hmmmmmm….

Well I don’t have time to do this.  I am just me. Not at the moment at least.  So if you think it is interesting to change the world you have a chance to grab one of the tasks on the TODO list of the VSCP project. It i hard work but fun also sometimes.  JavaScript people is most welcome at the moment as there are a lot of fun UX components to write.

The current TODO.

Cheers
/Ake

 

Categories
General

LG01 LoRa OpenWrt IoT Gateway

Nice an open LoRa gateway.

https://www.tindie.com/products/edwin/lg01-lora-openwrt-iot-gateway/?utm_source=twitter.com&utm_medium=referral&utm_content=tweet&utm_campaign=product_back_in_stock_tweets

Categories
General HowTo's

Howto: Practical use of #VSCP Remote Variables @thingspeak

See The story about an old fridge and VSCP module setup – refrigirator control part 1 , part 2, part 3, part 4  for earlier parts about this setup.

You have a VSCP system (or other system) setup that control something. and now you want to share some of this information up to the cloud.  One typical problem that you will see when doing this in a VSCP system is that data (we call it events in VSCP) is coming in with a higher rate than the rate you would want to publish it to the selected cloud service.  To solve this VSCP remote variables are perfect helpers.

A stream from a VSCP interface can typically look like this.

There is a lot of events coming in and often the frequency is even much higher that it is here. All the data above comes from a refrigerator and a fridge that is controlled by two Paris and one Kelvin NTC10K modules. Kelvin modules publish temperatures from a fridge, the kitchen and the upper and lower part of a refrigerator. The Paris module controls the compressors from these temperature measurements (ON/OFF events). The Turn-ON/OFF events originate from the Kelvin modules.  So when a temperature goes above a set point Turn-On events are sent from the Kelvin module after each temperature read and similar a Turn-Off event is sent when the temperature goes below the low set point. Nothing fancy really there.

We will look at one specific temperature only here, the fridge temperature.

This temperature comes from a Kelvin NTC10K module with GUID=FF:FF:FF:FF FF:FF:FF:FE B8:27:EB:0A 00:02:00:01  We find this out with the  VSCP Works tool which always is our friend when diagnosing a VSCP system.

We also see that the sensor is at  index 1 for this particular temperature sensor on the Kelvin NTC10K and that the temperature is sent in Celsius (Unit=1), exactly as we want to present it. Thus no conversions is needed.

Now, one way of sending this data to the cloud is to have a DM (decision matrix ) entry that send the data to the cloud every time it is received.

For this we just add an entry in the DM that calls a script when the  temperature event is received. This DM row would look like this

<row enable="true" groupid="thingspeak" >

<comment>
  Send value for fridge temperature to 
  Thingsquare
</comment>

<mask priority="0" 
 class="65535" 
 type="65535" 
 GUID=
"FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF
/>

<filter priority="0" 
 class="10" 
 type="6" 
 GUID=
"FF:FF:FF:FF FF:FF:FF:FE B8:27:EB:0A 00:02:00:01" 
/>

 <action>0x10</action>
 <param>
/srv/vscp/scripts/thingspeak.sh XXEIAQWY1XXNU6XX 2 %measurement.string
 </parm>

<allowed_from>0000-01-01 00:00:00</allowed_from>
<allowed_to>9999-12-31 23:59:59</allowed_to>
<allowed_weekdays>mtwtfss</allowed_weekdays>
<allowed_time>*-*-* *:*:*</allowed_time>

<index measurementindex="true">1</index>

</row>

Here the mask says that all bits of the VSCP class is of interest, all bits of the VSCP type is of interest and all bits of the GUID is of interest.  This is basically to say that the event we enter in the filter is the one we are interested in. So what we had entered in the filter is VSCP Class = 10 for measurement, VSCP type=6 for temperature and the GUID of the Klevin NTC 10K sensor that send the fridge temperature value.

Action is set to 0x10 (16) which says we should execute an external script. The param is the argument to this script.  The first part of the param is the path to the script to execute (which must exist and be executable)  and the rest is parameters. So here we execute the script /srv/vscp/scripts/thingspeak.sh and send three parameters

XXEIAQWY1XXNU6XX    2    %measurement.string

to itThe first parameter is the publishing key to the thingspeak service, the second is the number of the Thingspeak field we want to upgrade. The last parameter is the current temperature in the fridge. The %measurement.string will be replaced by the actual temperature before the script is executed. There are plenty of escapes one can use in decision matrices. 

The script that is called is simple and looks like this

#!/bin/bash
 # Arguments
 # =========
 # 1 - Write key
 # 2 - Filed number 1 .. n
 # 3 - Value
 #echo() { :; } # comment line to enable debugging

update=$(curl --silent --request POST --header "X-THINGSPEAKAPIKEY: $1" --data "field$2=$3" "http://api.thingspeak.$

echo "Update #$update"

# Uncomment to get debug output
 #echo `date` - "$1 field$2=$3" >>debug

Pretty straight forward. Check the documentation up at Thingspeak for the full process.

So what we got now is a DM entry that will update the cloud data as soon as the measurement event comes in. If it, as in this case is received with a frequency less than ten seconds, this may be pretty wasteful of  server resources. Better to update the cloud data at even time intervals.  How do we do this using the VSCP server?

we use one of the built-in events of the VSCP server, the minute event which is feed to the DM exactly once every minute.

To do this we first write the fridge temperature to a variable every time the event is received. We select a non persistent variable as it is no use in saving this value between session. The DM entry for this looks like this

<row enable="true" groupid="fridge" >

<comment>
 Store current temperature for fridge in remote variable fridge_temp
 with typ float (5)
 </comment>

<mask priority="0" 
 class="0xffff" 
 type="0xffff" 
 GUID="FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:Ff:FF:FF:FF:FF" />

<filter priority="0" 
 class="10" 
 type="6" 
 GUID="FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:0A:00:02:00:01" />

<action>0x50</action>
 <param>fridge_temp;5;false;0;0x777;%measurement.string</param>

<allowed_from>0000-01-01 00:00:00</allowed_from>
 <allowed_to>9999-12-31 23:59:59</allowed_to>
 <allowed_weekdays>mtwtfss</allowed_weekdays>
 <allowed_time>*-*-* *:*:*</allowed_time>

<index measurementindex="true">1</index>

</row>

So now whenever the event that holds the fridge temperature comes in it is written to the VSCP remote variable fridge_temp .

With VSCP Works we can list check that the variable is available

and it is, fridge temperature is currently -19.43 degrees Celsius.  As you can see we have added the other measurements of the fridge and the refrigerator to variables as well.

Now with the fridge temperature in a variable we can easily access the fridge_temperature remotely  using websockets in a webpage or if we prefer the REST interface  better it can be used instead.  But also the TCP/IP interface or the MQTT interface of the VSCP server can be used. Actually display the fridge temperature in a widget on a web pages is just connecting it to the variable.

But here we want to send the value to Thingspeak every minute so we add another row in the DM that looks like this

<row enable="true" groupid="thingspeak" >

<comment>
 Send fridge temperature varible value to Thingspeak
 </comment>

<mask priority="0" 
 class="0xffff" 
 type="0xffff" 
 GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<filter priority="0" 
 class="65535" 
 type="6" 
 GUID="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00" />

<action>0x10</action>
 <param>/srv/vscp/scripts/thingspeak.shXXEIAQWY1XXNU6XX 2 %variable:[fridge_temp]</param>

<allowed_from>0000-01-01 00:00:00</allowed_from>
 <allowed_to>9999-12-31 23:59:59</allowed_to>
 <allowed_weekdays>mtwtfss</allowed_weekdays>
 <allowed_time>*-*-* *:*:*</allowed_time>

 </row>

In this DM row we use the same script as above but now instead of triggering on the Class=10,Type=6 (A temperature measurement) we trigger on Class=65535, Type=6 which is the internal minute event. So now the fridge temperature will be sent up to the cloud server every minute instead of each time the measurement event is received. We can do this for all other fridge/refrigerator measurements also and send them all in one call up to the cloud server. Much more efficient.

You have the live result here.

Note the abstractions here. A driver on the VSCP server can collect data from a device of any type, transported over any net using any protocol  etc and it will end up well-defined here. This also works the other way around as the data can be sent out over any protocol, using any carrier and ending up on any device. One simple driver is all that distinguish one type from another and this driver can make everything look like it is a VSCP aware thingi from the VSCP servers point of view.

Task completed.

Hardware Setup: Here the VSCP Server is running on a Raspberry Pi. The fridge and the refrigerator and the modules is connected with CAN and the Pi uses the CAN4VSCP driver with the Frankfurt RS-232 module with a serial USB adapter to talk to the bus. Ethernet, Wifi, sub MHz RF, or whatever could have been used instead of CAN, but the powered CAN4VSCP bus is both low-cost, reliable and perfect in many other ways for a setup like this.