Categories
VSCP

Motivation #IoT #VSCP #m2m

IMG_1809

Working with a new administrative interface for the VSCP daemon.  One must think that by taking one step at the time, one will eventually reach the top, or at least, by continue digging, even on your own, it will eventually, at last,  be a big hole.

Categories
VSCP

#VSCP multicast #IoT #m2m

Screenshot from 2016-04-20 09:24:55

224.0.23.158

Yes VSCP has a multicast channel assigned. The above is the assigned IPv4 address for it.

Announcements

All higher level IP equipment should send announcements  on this multicast address. The port used is 9598, the registered VSCP port.

This means that if you want to know what units are on a multicast segment you just listen on this channel.

Announcements can be of three different types

  • VSCP daemon announcements. Announce the availability of a VSCP daemon (or other server with exported interfaces) and tell its capabilities.
  • High end device announce. Announce the availability of the device and its capability. All Level II nodes should have this functionality. At the bottom line they just look to the system as a VSCP daemon with fewer capabilities.
  • Heart beats: Heart beats come in the form of heartbeats from VSCP daemons and from high-end nodes. Both send them out each minute. Also heartbeats are available form devices connected to a daemon or through a high-end node.

User multicast channels

Users can set up proprietary multicast channels  using some other port than the VSCP assigned 9598. This makes it easy to create groups of VSCP nodes that can communicate with each other in much the same way as on a CAN bus.

Two factors that must be taken into account is the unsecured nature of this type of communication. Delivery is never guaranteed. But most of the time this is not a problem in VSCP if one design the event exchange around it. That is that a node that digest an event also send some sort of confirm/information event when doing so. The other problem is that it is easy to go in a mess about with the traffic for a user that is not allowed to do that.  Something that is  easily solved with cryptographic routines. Some VSCP standardization (and samples)  will come here in the future.

You can read more here.

Categories
VSCP

The VSCP GUID #IoT #m2m #VSCP

20160415_142722

Today I am writing about the globally unique identification code (GUID). Can it be more boring than that?  Well maybe not, but it is needed in VSCP, and it is important for any VSCP system to work.

Lets get started.

First the VSCP GUID is 16-bytes and looks something like this

FF:60:83:12:111:49:A0:1C:00:97:97:C8:CC:02:01:42

Sixteen hex bytes forming a globally unique id. MSB is to the left. An empty or unassigned GUID is represented by all nills

00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00

you can see this in many configuration files where the GUID is expected to  come from some other place. This unassigned GUID should never be used on a working system.

By writing to guid@vscp.org and request a GUID series you can get a series of GUID’s for your own project. Doing so you will get something like

27:00:00:00:00:00:00:00:00:00:00:00:XX:XX:XX:XX

(this GUID btw belongs to Grodans Paradis AB).

The XX:XX:XX:XX part is what we have for our own devices.  So with it we can start out and set

00:aa:bb:cc

for product series 00 (aa:bb:cc is increased for every built unit) and products series 01 get

01:aa:bb:cc

etc.  Or we just have a number that is increase for every product made. Or we request a new series of GUID’s for each product series. The important thing is that no other device on earth (or in the universe for that matter) should have the same GUID.

Requesting GUID’s is btw free of charge. After all VSCP IS free, will be free and is proud to be free and open forever. We may starve to death in the process of keeping it that way though. I can promise GUID’s (and VSCP) will still be free.

You can find current assigned GUID’s here.

But wait now, with VSCP being the protocol of the world, the IoT framework that unite them all, every IoT makers first choice etc, should it not be a lot more people requesting GUID’s. (Note: Joking here (Note: At least try to. ) )

Well one of the reasons is that you actually do not need to request a GUID, you probably have one already, or more precise you can form one.

For example if you have a machine that have an Ethernet MAC address you are in the free. Using it you also have a series of GUID’s you can use.  The reason is that some GUID series has been set aside for other id series. You can find them all here.

FF:FF:FF:FF:FF:FF:FF:FE:YY:YY:YY:YY:YY:YY:XX:XX

The series

FF:FF:FF:FF:FF:FF:FF:FE:00:00:00:00:00:00:00:00

is set aside for Ethernet MAC range. The

YY:YY:YY:YY:YY:YY

is the MAC address (MSB left, first), and

XX:XX

is the part you can assign to your own devices.

There is also a range set aside for IPv4 addresses

FF:FF:FF:FF:FF:FF:FF:FD:YY:YY:YY:YY:XX:XX:XX:XX

where again

YY:YY:YY:YY

is the IPv4 address and

XX:XX:XX:XX

is the bytes you can use for your own devices.

If you look at the list there are many other possibilities to form GUID’s from other unique ID’s.

Where is it stored?

Every device have a GUID and it is stored in the standard register space from where you can read it. You find it at address 208/0xD0-223/0xDF for a Level I device and on address 0xffffffd0 – 0xffffffdf on a Level II device.

Proxy GUID’s

When a device send you an event in higher level software the GUID is usually part of the message. For instance you can get a temperature sent to you from a device with GUID

FF:FF:FF:FF:FF:FF:FF:FD:C0:A8:01:33:01:02:00:04

and then when you read the GUID from the actual device you get

32:00:00:00:00:00:00:00:00:00:00:00:20:13:02:88

which appears to be wrong. But it isn’t actually wrong, the temperature event from the device have just probably passed another interface which acted like a proxy for the actual device.

This is not as hard to understand as it sound.  GUID’s are 16 bytes and therefore far to big to use in many low-end transmission media. On the CAN bus for example VSCP uses only one byte for its id.  This byte is called a nickname id as it is a nickname, a simpler version, of the full GUID.  Other systems may have 16-bit nicknames and even other formats.

The thing with VSCP nicknames is that when they pass an interface they wil take the interfaces GUID and place the nickname in the LSB. So the GUID

FF:FF:FF:FF:FF:FF:FF:FD:C0:A8:01:33:01:02:00:04

comes from an interface

FF:FF:FF:FF:FF:FF:FF:FD:C0:A8:01:33:01:02:00:00

on a machine with IP address 192.168.1.51 (C0:A8:01:33:01) .  On that interface a node has reported a temperature and that node use the nickname 04 or 0004 on the subsystem connected to the interface.  I can now communicate with that device on this GUID as it was the GUID of the device itself and actually it is in a way.

GUID’s are used for everything in VSCP. Locations also have GUID’s. Servers have them. The principle is simple. Very simple indeed.

That was all for this week.  Enjoy your weekend. I will work with a new admin interface for the VSCP daemon this weekend.

Cheers
/Ake

Categories
VSCP

Registers and abstractions #IoT #m2m #VSCP

power_injector5

Every VSCP device have registers. Registers abstract the settings for any device. Actually a non VSCP device can have a driver that abstract the devices actual setup, whatever it is, into registers.

So what is a register? In VSCP it’s just a byte wide position that can be read or written. Hence to configure a device one simply write registers, to find out the configuration of a device one simply read registers. Two simple operations. Read and write a byte.

Registers is divided in two types. User registers and standard registers. The standard registers is you will find at the same location on every device, that is  in position 80-255 on level I devices and at 0xffffff80 – 0xffffffff on Level II devices.

Standard registers contain information about a device.  The most important information you can find here is the 16-byte GUID which is a globally unique id for the device and the MDF URL which locates the Module description file. You can find firmware version, alarm status and a lot of other information here as well (more info here) .

As the standard registers is at the same location on every device and they always have the same type of content they are easy to use without any more information. The user registers on the other hand can contain anything the maker of the device want them to contain. Actually we call the registers a register abstraction model as they often model a more complex setup that may look like it needs more than just a bunch of 8-bit registers.

For a level I device there are 128 user registers available in the range 0-127. But this register space is also paged into 65535 pages.  Level II device use 0-0xffffff80 for user registers.

As the standard registers can contain anything there is a need for a description on their content. This information is available in the MDF (Module Description File). This XML files location is pointed out in the standard register space and can be fetched by software that need to configure the device. The pointer is a standard URL so the file usually is located on a standard web server.

You can read about the full content of the MDF here.  An example real life MDF is here.

The register content of a device is specified in the MDF. Typically a record looks like this

<reg page="0" offset="11" bgcolor="0xFFFFCC">
<name lang="en">Relay 1 control register</nam>      <description lang="en">The relay control bits enable/disable intelligent relay functionality:\n
Bit 0 - Enable pulse.\n
Bit 1 - If set: Alarm sent when protection timer triggers.\n
Bit 2 - Protection timer enable.\n
Bit 3 - Send On event when relay goes to active state.\n
Bit 4 - Send Off event when relay goes to inactive state.\n
Bit 5 - Send Started event when relay goes to active state.\n
Bit 6 - Send Stopped event when relay goes to active state.\n
Bit 7 - If set to one the relay is enabled.\n
</description><access>rw</access><bit pos="0" default="false"><name lang="en">Reserved</name><description lang="en">This bit is reserved</description></bit><bit pos="1" default="false"><name lang="en">Protection alarm</name><description lang="en">If set: Alarm sent when protection timer triggers.</description></bit><bit pos="2" default="false"><name lang="en">Protection timer enable</name><description lang="en">
If set: Protection timer is enabled and will deactivate relay channel when the timer times out.
</description></bit><bit pos="3" default="false"><name lang="en">On event on activate enable</name><description lang="en">
If set: An on event will be sent when the relay is turned on.
</description></bit><bit pos="4" default="false"><name lang="en">Off event on deactivate enable</name><description lang="en">
If set: An off event will be sent when the relay is turned off.
</description></bit><bit pos="5" default="false"><name lang="en">Started event on activate enable</name><description lang="en">
If set: A started event will be sent when the relay is turned on.
</description></bit><bit pos="6" default="false"><name lang="en">Stopped event on deactivate enable</name><description lang="en">
If set: A stopped event will be sent when the relay is turned off.
</description></bit><bit pos="7" default="false"><name lang="en">Enable relay</name><description lang="en">
Set this bit to make the relay controlable.
</description></bit></reg>

In this case a description of the bits in a register and how they make the device behave as they are set or cleared.  This register is at location 11 on page 0, usually written as 0:11.

Note that we can reach this level of abstraction with a protocol that have only two operations, read and write, it’s hard to think of a simpler protocol than that.

The intended user of the MDF is a configuration software. This piece of software read the MDF location from the device, download it from the server, parse it, and can then help a user to set up a device. Good thing is that one piece of software works for all devices. Later we will explain the wizards that are available in the MDF which makes this even more useful.

Abstractions

A register is an 8-bit location as we said. Now how about storing things, like floating point value, that does not fit in an 8-bit location. Well the answer is simple of course. Store them in multiple 8-bit locations.

To describe this abstractions are used. Abstractions sit on top of registers and specify how higher end types such as integers, strings, floating point values are stored in register space. So a higher end software usually does not bother with registers it instead  work with the high level types it usually deal with.

An example from the same MDF we sampled before

<abstraction type="short" default="0" page="0" offset="18" bgcolor="0xCCFFFF"><name lang="en">Relay pulse time register for relay 0</name><description lang="en">
This is the pulse time for the each relay expressed in seconds.
This can be used to have a relay turn on and off with a certain
preset interval. The min pulse time is 1 second and the max time
is 65535 seconds which is about 18 hours. Set to zero (default)
for no pulse time i.e. the relay will be steady on/off.\n\n
To start a pulse sequence first write the pulse time to this
register and then write 2 to the relay status register to start
the output. The pulse train is terminated by writing on or off
(1 or 0) to the relay status register.\n
</description><access>rw</access></abstraction>

show an integer that has its MSB at pos 0:18 and it’s LSB at 0:19 (Everything in register space is stored MSB first)

Software tools  like VSCP Works (available in the  VSCP & friends package) can handle configuration of any device. Some web-based tools is on the way to do the same.

There is no need for things to be more complicated.

 

 

Categories
VSCP

Autonomy #IoT #m2m #VSCP

floorplan_button_example

Yes I know. It’s all about the cloud nowadays. Every device should post their data up to the cloud and allow themselves to be controlled from the cloud. So I will talk about autonomy of a VSCP setup today. Well I know. It’s kind of the opposite to the cloud model as no cloud is needed. But wait, don’t go away, you can have the cloud and autonomy at the same time. Promise.

VSCP is an event bases system. Events are sent by nodes when things happen. The node that originates the event does not care if there is one or two or three receivers. It just originate the event for anyone to receive (must-be-in-the-cloud people: yes the event can be sent up into the cloud).

So another node receive this events, find it interesting, and do something with it. For example if the event sent was CLASS1.CONTROL, Type=TURN-ON (the standard event to turn things on) the receiving node will turn the thing(s) it is supposed to turn on and send CLASS1.INFORMATION, Type=ON (the standard event to tell that something has been  turned on) to tell interested parties that it has turned on a device.

This is typically how the VSCP event system work. An event is sent out and if something happens at a point and a receiving device  take interest in the event, this device also sending out an event telling the system it did something.

The ping-pong mechanism described above where a reply is sent when something is turned on can be used to validate that the expected operation actually has been carried out.

(Must-be-in-the-cloud people: yes the event can come from the cloud and the “response” can go to the cloud).

Well most systems around typically have a server in the system (or a server in the cloud). VSCP does not need one (but CAN have one). Because when a VSCP system is configured it behaves like an autonomous system. All this is possible because of the decision matrix (DM) that can be implemented  in a VSCP node..

The decision matrix

We will only discuss the Level I decision matrix here.  Made for low-end devices, The Level II works mostly the same.

The decision matrix is a 8-byte entity and a device can have zero or more rows in its matrix.  The purpose of the DM is to say

When an event of a certain kind comes in do something.

And the “do something” part of a decision matrix row is called an action. Take a look at the Paris Relay module for some action samples. This is typical for all modules. It has a few well-defined things it can carry out. In the case of the Paris relay module  turn on a relay, turn of a relay and so on.

As the DM looks the same on all VSCP devices it is easy to make a user interface that configures it

  1. Let the user decide which event(s) should trigger the action.
  2. Select from where the event should come.
  3. Select what action should be performed.

Same for every device.

When this is configured  for a devices it will work  autonomous from that point on. Incoming event’s will be feed through the DM of the device and if a match is found the action will be performed.

No server needed.

 

 

Categories
VSCP

Measurements in VSCP

kelvin11-500x500

Today’s topic is measurements.

Abstract: We show why a well-defined binary datagram content is an advantage over a textual content for measurement data on a wire.

When you see

42

you see two Arabic numbers and probably guess it’s a number in the decimal system. So it’s 40 + 2. But if you are on the receiving end of a communication line what is 42 then? Does it mean anything to you?

Well it could be anything. If the sender sent this number 42, as a temperature you don’t know that it is a temperature  on the receiving end without further information sent or it must be sent on  a channel dedicated for just temperatures. Also you don’t know the unit without more information added. The temperature could be expressed in Kelvin, Fahrenheit or Celsius or even some of the other possible units that are used around the globe.

Still this is how most measurement values are sent. Sometime with adding information like

Temperature: 42 Kelvin

often all packed in XML or JSON envelopes and in text form. Alternatively you will find manifests by packed with the measurement data, big ones, with lots of information and options. Always in textual form.

All this is good and fine for higher end nodes. They have the memory to handle the conversions, the power to do the translations fast. No problem. But for sensor it gets a bit stupid. They are often cost sensitive devices and the processing power will therefore be lower and parsing and memory usage should be kept low. It’s just plain stupid to use high level structures on this level.

The VSCP solution

In VSCP, measurements, like everything else, is identified by a class and a type. There are a few different classes available that handle measurements, but  let us look at the lowest end form here, made to make it easy for small devices to handle this kind of information in a resource efficient still safe way.

The measurement types in VSCP is fetched from the SI system. So all measurement type used in science and engineering is there and is so in a standardized form. Some examples

  • Temperature: Class=10 Type=6
  • Frequency: Class=10, Type=9
  • Pressure: Class=10 Type = 12

you get the picture. You have them all specified here.

All measurements in the SI system have a default units. For temperature  this unit is Kelvin. But people are used to use the more everyday common  Fahrenheit and Celsius. This is true for all other measurements to, so in addition to the class and type to define which measurement is sent VSCP also send which unit this measurement is in. For the low-end devices, four well-defined unit types  is available for each measurement type.  For temperature unit = 0 is Kelvin (zero is always the SI unit), unit=1 is Celsius, unit=2 is Fahrenheit.

Last the format of the data is specified and some other information is also available which we will not go into here (full info is here).

The end result is a very compact measurement record that contain all relevant information. In this case 42 degrees Celsius is packed in seven bytes. Perfect for slow communication lines like RF.

The advantages of this format is

  • Small packets with all needed information specified.
  • Easy to handle by a low en device.
  • Unit and type is always well specified.
  • Value coding is always well specified.
  • A unified format means uniform handling.

The uniform handling is interesting. This means that one solution can be used to, for example,  draw diagrams for all types of measurements, same for statistical analysis or other analysis or just handling data. Well you get it. A big time and resource saver and no more stupid mistakes (making us miss Mars).

Sync

VSCP is not specially designed to be used in real-time systems. Still if we talk about milliseconds and 10th of microseconds it is usable.

For Level II events in VSCP, which  have a timestamp in the package, this is no problem. Here we have microsecond resolution. But for low-end links the over head of a Level II event may be too much.

Level I events does not have a timestamp in the package. They are time stamped when they are received instead. This may not be enough in some situations.

Solution 1

The sync event (class=30, Type=26) is perfect if you want to  synchronize measurements from several remote modules. Send the sync event on timed occasions and the nodes will respond in a synchronized fashion.  You can timestamp them from the time you sent out the sync, optionally taking in to account the round trip time.

Solution 2

Instead of sync a node that send measurements can send a time event (Class=10, Type=4), using unit= 0 the timestamp can use millisecond resolution

OK that was all for today.

 

Categories
VSCP

Thanks

vscp_new_v2

Thanks for supporting VSCP (you now who you are). I really appreciate the contributions received after my last call out.

THANKS!

Categories
VSCP

VSCP firmware update

5

Updating firmware on a piece of hardware in your system is essential to keep it up to date.  VSCP can handle both it’s own firmware loading algorithm or uP specific algorithms for greatest flexibility.  But how does it work? Here is a short step by step walk through.

1.) A module should be updated with new firmware.

2.) The MDF (module description file) of the module is read form the manufacturers web server.

3.) By reading standard register 0x97 (or 0xffffff97 for Level II devices) the bootloader algorithm the module uses can be determined.

This information is also in the MDF under the boot tag

<boot>         
        <algorithm>1</algorithm>     
	<!-- Size of boot block/sector -->     
	<blocksize>20</blocksize>          
	<blockcount>66</blockcount> 
</boot>

4.) The MDF also contain available firmware for this module under the firmware tag.

<firmware path="url where firmware can be found" 
				format="intelhex8|intelhex16|intelhex32"
    size="Optional size in bytes for firmware file (not image)"
    date="ISO date year-month-day when released."
    version_major="x"
    version_minor="y"
    version_subminor="z">
    <description lang="en" >Firmware description</description> 
</firmware>

One can now  let a user select the firmware to load or load the latest available firmware.

The same security applies to firmware upgrades as for the rest of the system.

Categories
VSCP

VSCP and the big money

open-source-logo

A big problem for all people working with open source is how to finance the time it takes to do the work. For instance am I in the process now of adding a real web admin user interface and databases and other high level things to the VSCP  & Friends suite. This is work I estimate will take up to six months. Yes that is full time or more likely around 16h/day for a full seven days of a week. That is a long time without a possibility to take other paid work.  Yes and there are hosting bills, electric bills, and all the rest of the  bills a company have, and they all need to be paid by open source people to. Yes it is strange. I know. Who could ever thought it was like that? 😉

Fortunately  the project get some donations from time to time. That is a big help and I really would like to take the opportunity to thank everyone that have sponsored the project over the years.  But donations counts for only about one percent or less of the total cost to run the project.  The rest is money I have to take from my own pocket. Multiplied with the sixteen years the project has been on the road this adds up to quite some large sums I can assure you.

I know we are not as used to supporting free projects  in Europe as people in the US are,  but anyway I ask all of you guys out there who like the project or even use it, to support the VSCP project  with a few cents or a couple of Euros, or even  with some hands that can help. Make life a bit easier for  this free and open alternative for an IoT protocol.

Donations can be sent using the donate button on the home page.

/Ake Hedman

Categories
VSCP

VSCP turns 16 today

vscp_new_v2