Get Response from a Status command

Hello

I am using the Jvelbus Api (java) that someone developed for handling the bus. It’s the same as the one developed in .Net.

I would like to know how to get the response for a Status Relay Message.

It’s sent via the sendBlocking() method. So it’s blocking the bus to send message.

Now via the ReceivedPacket Listener I will receive the entering response. How can I be sure that the response matches to my question?
How can I put in place this link mechanism between the question and response?

thks

Valery

You are correct in a way, but it mostly means that it will block the current thread

You can’t. Communication is asynchronous, meaning packets will be received and sent ‘randomly’.

  1. Always wait for packets and read them
  2. Interpret packets as they come in
  3. Send packets yourself to get information or send a command

If you receive a status packet, interpret the status, and store the status. If you want to know the status later on, well, you’ve just stored it so you still know it :slight_smile:

hi Valery,

you have to compare the sended message and the recieved message for matching address and relay channel.

hope this will help you,

Stis

So I have to somewhere save my sent data and compare with data that I have to receive : Address + extra data.

Correct?

Would it be sure that I will always receive a response? if not, does it exist a limit deadline?

thks

valery

[quote]So I have to somewhere save my sent data and compare with data that I have to receive : Address + extra data.

Correct?[/quote]

Use logging in VelbusLink to get to know the protocol

No

No

You have to implement a state machine, not action<->reaction

VEL448, stop me if I’m saying something bad ! :slight_smile:

I’m programming apps with Velbus (especially PB_Velbus-Server which is an Ethernet/Velbus bridge). Velbus bus communication works like Ethernet UDP communication.

Then, there are two way to have a feedback :

  1. create a process that log each frames in a list (chainedlist, etc) and then search in this list after sending a command frame (but you have to wait a least 10 ms before searching)

  2. send a command frame et start a loop with a timeout (3 sec are enough). In this loop, read and analyze each frame. If timeout occurs, you can try to request a status on module choosen or send it again the same frame.

Responses aren’t guaranted, because a high priority message can be transmitted at the same time than the answer (is the process like CSMA/CD on Ethernet protocol ?)…

If you want to use PB_Velbus-Server (PB is accronym for PureBasic, the language I use), you can connect many network applications on the same server (for example, on a PC you can use VelbusLink and in same time, on an other PC you can send/receive Velbus frame)
That way, you can use VelbusLink analyzer (logging) and read same frames on my server (you can save them as text file in the same directory).

I hope you a good luck : Velbus gives us a great hardware, we just have to create funny software :slight_smile:

Hello

Yes Golfy I already the advantage of your tool. I think that I will use it.

Thinking about my application design :
Thing that I wanted to do:

  • a web interface with a bulb light. When I go on this page, every 5 sec, I am doing a refresh of the status of my bulb light component to check if it’s on or off.
    The limitation of Java/.net libraries, if I send a message to the bus to know the status of my component, I have to implement by myself a mechanism linking my request and my response + mechanism to wait if response take a long time to come + handle the case of I don’t receive a response.

So with info that you gave me I think that I will design it differently :

  • at each time that a component changes of status (light on or off), I catch the message from the Velbus inside my application and change the status of my Light Object.
  • on my web page, every 5 sec, I will check the status of my Light object defined in my application.

Could you give your idea about it?

thks

V.

[quote=“vdetez”]each time that a component changes of status (light on or off), I catch the message from the Velbus inside my application and change the status of my Light Object.

  • on my web page, every 5 sec, I will check the status of my Light object defined in my application.[/quote]

That sounds absolutely perfect!

[quote=“VEL448”]

[quote=“vdetez”]each time that a component changes of status (light on or off), I catch the message from the Velbus inside my application and change the status of my Light Object.

  • on my web page, every 5 sec, I will check the status of my Light object defined in my application.[/quote]

That sounds absolutely perfect![/quote]

+1
I’m working on a similar (secret) project (code name : VELTRON). In fact, it would works on Windows OS, maybe Linux (if I could compile in this environnement because even if Purebasic is cross-platform, my knowledge isn’t enough at present time :frowning: ).
However, your project seems to be compliant from any browser… even on Android/iPhone ?
By the way, you’ll have to do a scan of all modules first (to determine TYPE – one by address – and each part NAME – here you can have many NAME on one address because VMB4RY support 4 relays by example) : That means it’s better to manage ‘part’ as independant object :wink:

Happy to see someone using one of my tools : I was beginning to think I works for nothing :wink:

Hello

What do you think? When I want to toggle an relay channel (to switch a light on/off), do I need to use the send() or sendBlocking method?

Thks

Valery

Have you tried either of them?

No. I am used the sendBlocking() one but I don’t know if in case of problem, if it won’t block my code.

kr

Valery