I don’t manage to get the relay status of a VMB4RY via code, I can get the name of the relay ok, but not the status.
packet.Address = 0x00; // change this address to reflect your setup
packet.Priority = PacketPriority.Low; // low priority command
packet.DataSize = 2; // 2 data bytes
packet.Command = 0xFA; // Command "Get Status"
packet = 0x01; // We want to get status on Relay 1
And this is the sent package:
Packet sent to address 0 - command:fa - data: 0f fb 00 02 fa 01 01 04 00
But there is no answer…
What am I doing wrong?
Edit: In the velbuslink software (latest release) the relay status is always “Off” in the watchlist, no mather the real status.
Is this a known problem, do I have a defective relay, can I reflash the damn thing?
I’m writing my own domotics solution so the status of the relays is quite important…
Velleman, please help!
You code looks perfect, except for the address Maybe you already did this, but you need to give your modules a valid address. Modules with address 0 will not respond to most commands.
packet.Address = 0x01; // don't forget to change the address on the module itself (rotator switches)
Just noticed this. This is also because the module’s address is 0
Ok, that’s the solution, I keep that in mind!
Thanks for the support, I have to say, GREAT product!
I’m in the process of writing my own objects to control the modules, I’ll post my progress on the forum for the rest of the developers out there.
Just a remark, you have to use packet.Priority = PacketPriority.Low or you won’t get a reply.
If the protocol description says
SID10-SID9 = 11 (lowest priority)
Seems I missed that part…
At the moment I’m working on a function to call the name of the module.
The request is no problem, but parsing the answer from the flood of bus messages isn’t…
Do you by any chance have a code snipped how you guys did this in VelBuslink?
I thought of buffering the last 50 received messages or so and than go find the messages with the right name in the buffer, past them together for the name and return the name. But I can’t believe this is a reliable solution.
An other way would be to let the program pick up all the messages and wait till all 3 responses are received, discarding any other messages but not shure yet how to implement this.
Any advice would be welcome.
You can assume that you will always receive three packets
- COMMAND_RELAY_NAME_PART1 (&HF0)
- COMMAND_RELAY_NAME_PART1 (&HF1)
- COMMAND_RELAY_NAME_PART1 (&HF2)
What we do is:
- Check if the command is in the range &HF1…&HF2]
- Keep three small binary buffers in which to store the parts of the channel’s name as they come in (BYTE buffer)
- You can get the correct buffers index by subtracting &HF0 from Packet.Command (results in 0…2)
- Only when the last part has been received (&HF2), it’s time to glue the three buffers together to form a string
Note: &HFF is the string delimiter
If any other packets are received meanwhile, you can just process them as usual.