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.
This page is a short tutorial showing how to display temperature on a web page in real time using websocket.
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.
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).
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:
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: