VSCP over CANbus with Atmel devices - PART 3 - Using the daemon

This page is the next step after PART 2

If you have completed PART 2, you should be able to receive events from the CAN bus using VSCP Works. We will see now how to use the daemon to receive events.

You can read the daemon documentation to see how to install it on a Unix system.

This page is a short tutorial showing how to display temperature on a web page in real time using websocket.

Running the daemon

As you compiled and installed VSCP Works, you should have the executable file vscpd. Issue the following command to start the daemon:

sudo /usr/local/bin/vscpd -s

The daemon is now running, you can stop it with Ctrl+C.

You can set it later as a service in /etc/init.d but I will not describe this here as the procedure depends on your distribution.

Connect WORKS to the daemon

You can configure an interface in VSCP Works to connect to the daemon:

In the case above, VSCP Works runs on the same computer as the daemon. If not, replace localhost by the IP address of the machine that is running the daemon. e.g. 192.168.1.245:9598

Note: in the current versions of VSCP Works the Server Port field is depreciated and no longer used. The port is added behind the IP address in the Server URL field (as shown in the screenshot above).

Test received events with a websocket

You can access test pages at http://127.0.0.1:8080/testws/index.html

In this example we have temperature sensors sending temperature event on the bus.

You can access the test page for thermometer websocket here: http://127.0.0.1:8080/testws/thermometercelsius.html (replace the IP address with your server address).

It can be that by default the websocket cannot connect to the daemon, in that case it will show a red cross as below:

You need to update /srv/vscp/web/testws/settings.js with appropriate settings, mainly set the daemon server address:

var vscp_setting_url="ws://127.0.0.1:8080";

In the HTML file you can see an object called vscpws_thermometerCelsius. It is documented here. In my case I only had to change the sensor index to 0 as below:

var temp1 = new vscpws_thermometerCelsius( vscp_setting_user,
                                                    vscp_setting_passwordhash,
                                                    vscp_setting_url,
                                                    "mythermometer1",
                                                    0,
                                                    VSCP_CLASS1_MEASUREMENT,
                                                    VSCP_TYPE_MEASUREMENT_TEMPERATURE,
                                                    0 );

Then the websocket can establish the connection with the daemon and display the thermometer:

Where to go from here

PART 4 should cover a bit of the daemon decision matrix with an example showing how to save event information into a table…

 
howto/vscp_can_atmel_part3.txt · Last modified: 2014/11/06 21:48 by jmbeaune
[unknown button type]
 
Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki