Velbus and Raspberry pi

Hello

I am trying to connect my raspberry pi to Velbus via VMB1USB but whatever the library or client that I am using for connection (Jvelbus, velbus.c, client_velbus.c), I cannot connect to the bus.

here is the dmesg command
2.863003] smsc95xx v1.0.4
2.933191] smsc95xx 1-1.1:1.0: eth0: register ‘smsc95xx’ at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:5f:21:8e
3.027649] usb 1-1.3: new full speed USB device number 4 using dwc_otg
3.140485] usb 1-1.3: New USB device found, idVendor=10cf, idProduct=0b1b
3.157455] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
3.180124] usb 1-1.3: Product: VMB1USB Velbus USB interface
3.197477] usb 1-1.3: Manufacturer: Velleman Projects
5.370401] cdc_acm 1-1.3:1.0: This device cannot do calls on its own. It is not a modem.
5.667775] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
5.856442] usbcore: registered new interface driver cdc_acm
6.117453] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
11.976244] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
12.340592] ### snd_bcm2835_alsa_probe c05c88e0 ############### PROBING FOR bcm2835 ALSA device (0):(1) ###############
12.356423] Creating card…
12.361934] Creating device/chip …
12.368505] Adding controls …
12.373912] Registering card …
12.387662] bcm2835 ALSA CARD CREATED!
12.394696] ### BCM2835 ALSA driver init OK ###
18.518224] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1

Any idea?

thks

valery

What do you do exactly? The interface is recognized as ttyACM0. I’ll try my soft tomorrow on the raspberry pi (velserv which can be found here on the forum), normally this will not give any problem.
The only problem that I could think of are permissions, as which users do you run the scripts?

Hello Jeroen,

I don’t know what exactly happen. I just test to open a connection via JVelbus java API (which is run on my windows machine) and tried the client_velbus.c but for the first I have a Null Object and the second a Connection Problem (Not connected).

I am trying it via the “pi” user.

At each time I passed the /dev/ttyACM0 port and as read in your mail I have defined thing like tty -f /dev/ttyACM0 9600 (command that you mentionned in one of your mail)

Kr and thks for your help

Valery

Hello,
I’ve also noticed a problem running the server on the raspberrypi. Strange, this is the first embedded board which had this problem (others like ie. the olinuxino don’t have any problems with it).
the velbus server program I wrote consists of 2 programs in one. One is the distribution server and the other is the gateway (client) to make the server listen to the velbus interface.
The gateway opens the interface but seems to have a problem connecting to the server (the server works).

Will look further into it.

Ok found the error, euhm … not really an error.
The fact was that the raspberry didn’t create the server part fast enough so that when the client wanted to connect, the server didn’t exist at that time. This is now solved by putting a simple delay of 1sec befor creating the client.
Works back like a charm :slight_smile:

Download the source @ leachy.homeip.net/velbus/velserv.c
and compile with gcc -o velserv velserv.c -lpthread

more info about the usage can be found with ./velserv -h (like for ex a more verbose output: ./velserv -v -v -v -v -v , if you put more or less “-v”, you’ll get another verbose output)

1 Like

Hi Jeroen

Thks for your help. Hoping once created that I won’t loose it.

However in the java code I thought that I put it a sleep(5000) after to have open it before to send it a request.

Hum… I will retest it this evening

thks

Valery

i never tested the java code since I’m not so formiliar with java and do everything in “C” or in “perl”.

I will first test it in C

thks

Valery

Hello Jeroend

I have started the velsrv and here is what I have
pi@raspberrypi ~ $ ./velserv -v
Device : /dev/ttyACM0
IP address : 127.0.0.1
Port : 3788
Verbose level : 1
Client mode : 1
Server mode : 1

After What I have to do to interact with it?

thks

Valery

You now have a socket on port 3788 which can accept velbus messages (when using a more verbose level you can see those messages).
On this socket you can connect various client applications. One of them is of course the velbus configuration tool (there’s an option to connect over network). Other options are scripts which can be started through the crontab (at a specific time of day) or if you’d wish, I got also a timer with dusk/dawn capabillity.
Some of the other things that I do in linux are logging all my temperature modules with rrd, but I have to warn you, this is not recommanded on a sd card because it will wear it out (because of the limited read/write cycles), or for example a script that’s also running to control the lights and ventilation of my bathroom/dressing (all for user comfort and dimming), or use scripts behind your webpage to control velbus.
Last but not least: you can run domogik on your raspberry pi (domogik.org). Thanks to Cereal who wrote the code to interface with velbus, you can make your own user interface which is accessable through a webbrowser and has an interface for android (all free of charge, but still a bit development to do).

Then fun thing when working with sockets rather then connecting a script direct to your velbus interface is that all the above can be ran together.
I’d suggest you’ll have a look at the perl scripts in the webdirectory (I’ll post more of them tommorow) to have a look how a simple script works.

Hello Jeroen

I finally succeeded to plug on the Velbus. Effectively a quick sleep after the open and before the first actions was ok + reference the correct Rxtxcomm.so lib in my javacode.

In my code I also have to define the baudrate to 9600 in order to have it running.

However I still have a problem : I can send action to the bus via my java api but I can’t receive any data from the bus. For exemple I have listener which listens to the entering message and when I switch a light for example, I did not see any packet entering; same problem when I want to do a complete scan of the bus. No problem to submit message but nothing was received.
Any idea?

Anyone could you share me a simple piece of code to listen to my bus in C, python or perl? and validate by this process that it’s not due to my java API

FYI, with my raspberry I will use Openhab java library… with it, it’s really cool because I can create a beautiful UI and connect to different stuff via this appli (sonos music system for example)

kr

Valery

I had the same problem at first when I started my first testcode. I could send messages but I couldn’t receive.
At first I thought it had something to do with RTS not being high and DTR being low, but all that seemed to be ok. The only thing I 've noticed is when I used stty, just only the command and not setting anything, all seemed to work. I digged in the code of stty, but nothing special was happening over there and as time came by, I’d forgot about this problem since I called stty from my program at startup, just to bypass the problem. Problably you’re facing the same problem so I’d suggest you try and do the same as I did for now until someone has a brilliant idea on what is causing this problem (I’d even asked the writer of stty what he had done differently but he even had no clue).

ps: I seems that python doesn’t have this problem, problably it is using other lib’s to access the serial port.

Hi Jeroen

Ok I will investigate it deeply. Hoping that’s something special. I keep you in touch if it’s running

Kr

Valery

Baud rate is 38400
No parity bits
One stop bit
Eight data bits
No flow control
DTR disabled
RTS enabled

Jeroen,

Could it be that there is a minor error in your code if you run it with the port option specified ?
I did try to run it on port 8445 (default of the velbuslink) and it did terminate with the error “Velserv: error connecting client to server”

Looking closely to the C file i did notice that somewhere in the code port 3788 was entered instead of the variable PORT.
After changing 3788 to PORT it did run on the specified port.
Below the part where i did change 3788 into PORT

/*##################################################################################################
# socket configuration and activation #
##################################################################################################
*/

	host = gethostbyname(IP_ADDRESS);
	if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) 
	{
        fprintf(stderr,"Velserv: error creating client socket\n");
        exit(EXIT_FAILURE);
	}

	server_addr.sin_family = AF_INET;     
	server_addr.sin_port = htons(PORT);  <- changed 3788 to PORT 
	server_addr.sin_addr = *((struct in_addr *)host->h_addr);
	bzero(&(server_addr.sin_zero),8); 

	if (connect(sock, (struct sockaddr *)&server_addr,sizeof(struct sockaddr)) == -1) 
    {
		fprintf(stderr,"Velserv: error connecting client to server\n");
        exit(EXIT_FAILURE);
    }

FYI : i do run your velserv on a raspberry pi.

What do you use as frondend to control/view you velbus devices ?

Regards,
Jeroen.

Hello,
yep thats a minor error :slight_smile: I fixed it in the code.
For now I’m using some perl and c programs to add some extra functionallity. In the future it’s the intention to have domogik running on the PI as frontend, but there are still some minor issues. But I’m shure that wil be firugerd out very soon (as Cereal is working on them).

[quote=“jeroends”]Hello,
yep thats a minor error :slight_smile: I fixed it in the code.
For now I’m using some perl and c programs to add some extra functionallity. In the future it’s the intention to have domogik running on the PI as frontend, but there are still some minor issues. But I’m shure that wil be firugerd out very soon (as Cereal is working on them).[/quote]

Yeah last week i commited some changes to the velbus plugin for domogik.
It should run fine now

Hello,

I’m trying to use domogik with velbus plugin. For now using an old desktop but rapsberry pi is ordered.
I’m using an usb connection and the linux server by jeroends

I have a problem switing my VMB4RY , I can only switch channel 1, for other chanels I get :

RINOR : ‘No data or timeout on getting command response’ (/rinor/api/command/velbus/34-2/)

The light on chenel 2 goes on physical, but domogik doens’t get the reply code.
Although I see correct data on the bus :

Switch channel 1 on :
      127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 02 01                           => switch relay on
      127.0.0.1 on socket 06: add : 22 | prio : low  | rtr : off | data : FB 01 00 01 80 00 00 00  => Relay status
      127.0.0.1 on socket 06: add : 22 | prio : high | rtr : off | data : 00 01 00 00                   => button status
switch chanel 2 on
      127.0.0.1 on socket 07: add : 22 | prio : high | rtr : off | data : 02 02 
      127.0.0.1 on socket 06: add : 22 | prio : low  | rtr : off | data : FB 02 00 02 80 00 00 00 
      127.0.0.1 on socket 06: add : 22 | prio : high | rtr : off | data : 00 02 00 00 

I have tested with the nightly builds and beta1 builds.

domogic velbus log file, status relay 2 is missing there : …

2013-03-19 09:40:46,501 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 09:40:46,519 domogik-velbus INFO schema:lighting.device, data:{'device': '34-1', 'level': 100}
2013-03-19 09:40:46,527 domogik-velbus INFO schema:sensor.basic, data:{'device': '34-1', 'current': 'HIGH', 'type': 'input'}
2013-03-19 09:43:58,247 domogik-velbus INFO write packet
2013-03-19 09:43:58,247 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 09:43:58,275 domogik-velbus INFO schema:sensor.basic, data:{'device': '34-2', 'current': 'HIGH', 'type': 'input'}

Anybody knows what is going wrong ?

it seems that the velbus plugin is not seeing the status code for the second relay,

is there nothing in the log file for the second one?

nothing to see :

2013-03-19 09:40:46,500 domogik-velbus INFO write packet
2013-03-19 09:40:46,501 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 09:40:46,519 domogik-velbus INFO schema:lighting.device, data:{'device': '34-1', 'level': 100}
2013-03-19 09:40:46,527 domogik-velbus INFO schema:sensor.basic, data:{'device': '34-1', 'current': 'HIGH', 'type': 'input'}
2013-03-19 09:43:58,247 domogik-velbus INFO write packet
2013-03-19 09:43:58,247 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 09:43:58,275 domogik-velbus INFO schema:sensor.basic, data:{'device': '34-2', 'current': 'HIGH', 'type': 'input'}
2013-03-19 09:51:00,041 domogik-velbus INFO write packet
2013-03-19 09:51:00,041 domogik-velbus INFO START SENDING PACKET TO 0x22
2013-03-19 09:55:17,439 domogik-velbus INFO schema:lighting.device, data:{'device': '34-2', 'level': 0}

9h40 and 9h43 tried activating lights with domogic no return for channel 2 seen by domogic
9h55 light chanel 2 of with velbus link … return seen by domogic …

weird