Send command to serial port and receive a answer

so sending is working, but command isn’t ok :

also OFF on the end isn’t required. But it isn’t critical, because is send when switch goes to off position

tried some other modifications, but still no luck send as correct HEX

Any idea how to send correct HEX command ?

Its all just data going to serial port.

Connect you Heating device to your serial terminal the same as you did to openHAB

Then send it the request command.

hello are you there?

or something like
DLESOHBUSHBUSLRAMHRAML\n

See if you can “talk” to it using the command line first this will help to understand the commands as it should send you a response.

Once you get the request command correct enter it into the On Value it should come out exactly as typed

OFF must be the default value for “Off Value” set it to \n which will just ask for new line.

I already tested. Because I’m using USB/RS485 dongle, I can easy connect PC to the RS485 bus without any limitations and can see “online” communication.
I’m sure when I will send from original SW a command :
10H 01H FFH FFH 10H 30H F8H 02H E3H 61H FFH
Main unit will answer and send a data.
But when I will send this command from openhab, main unit will not answer
I tried to change a commant to \u00FF and \FF etc but no luck till now

All this stuff has to be exactly right with quotemarks, escape slashes, spaces, commas etc. and that depends on the context that you are trying to work in - rules, GUI config, etc.
You must show us exactly what you are doing.

Why a switch, you already know the serial binding needs a string

No, I’m not doing it for you, someone else might.

I have a problem to get working a rule to send a data
I have a channel receive:

and also send:

I created one special item switch for rule start:

and also rule:

with script:

but when I switch ON command isn’t send
I think I have wrong send channel defined. Also don’t know if it’s corrent that rule is in IDLE

I’m able get it working with switch configured:


but this isn’t good for my request

but looks like that receiving is working correctly. When I insert a text into putty, I can see also in serial_received.

I’d suggest enabling debug logging for the serial binding which will give a clearer indication in the openhab.log of what is being sent and received.

Can you then post the relevant bits from the openhab and events log when you set the switch to on

makes me crazy. I read tutorial regarding debug, but for me as newby is hard to understand. I must log via putty ? sorry I’m lost

exactly this I checked. I tried connect via SSH to port 8101, no luck. To port 8080 no luck. But thanks for the efford. Looks like instructions aren’t for begginers.

If you don’t say exactly what you’ve tried and what doesn’t work then it’s hard to provide help.

Regarding command sending to serial port a sent all possible screenshots from UI And did also translation of communication protocol. I can’t send a text version of my setup as in examples. Examples Are I think from other version of OH.
Regarding logfile: first I read a tutorial for loging. Instruction Is use file system or karaf. Who Is karaf? Ok karaf isn’t way for me, so file system. Ok file system Will do a online monitoring … Aha i can see a lot of instructions in tutorial. So clear is I must connect to console. Open tutorial for console. First information is: all depends how you started OH . For me not clear So i decided try connect via ssh. Ok, next part of tutorial. Information is: use port 8101. Ok i opened PuTTY And try IP + port. Connection refused. Next I tried port 8080. Also refused. Then I used default port 22. Ok password And name. Openhab And habopen… Refused, Wrong login. So this Is my situation. But also can write more details if it will help.
Sorry for long post. I’m little bit frustrated how big misson imposible is so stupid action like send command to serial port. On arduino or VB or C++ it’s on line instruction. Also in node red it’s easy job. But step by step and method test/error maybe on the end will win.
Regarding serial port bridge - I really don’t know why there are channels with information that they are for sending/receiving commands, because I must make a serial device linked to brige. And information in channels in serial device is, that they are for receiving commands. Not a single word about sending. Strange.

Ok take step back because I am getting confused.

When you did connect openHAB to your serial port with putty you can see the data coming out of openHAB. I suggested doing it this way because it is less to learn and you don’t have to modify config files to get better logging you can just see the commands as they come out.

now forget about openHAB for a sec.

Connect putty to your heating device and enter request. When you get a response from the heater post results.

This is to your determent. You know too much and expect openHAB to be like other software. You can use multiple languages in different ways to achieve the same result.

In the GUI you can select the code tab and edit code that way.

Something like

triggers:
  - id: "0"
    configuration:
      itemName: ?
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: script
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >
        // context: Send String to Serial Port
        var data = "[“0x10”,“0x01”,“0xFF”,“0xFF”,“0x10”,“0x50”,“0xF8”,“0x02”,“0xC3”,“0x01”,“0xFF”]"+"\r"
        heating.sendCommand(data)

    type: script.ScriptAction

Can you send the command from PUTTY?

I will guess that you are running openHABian on a PI.

Connect to PI with PUTTY (e.g. "openhabian :openhabian ")
once you are connected to openHABian you can then connect to the openHAB Console

Enter ssh -p 8101 openhab@localhost onto the command line of the SSH session you have already opened

1 Like

So putty: When communication is running looks like this :

so I must save a communication log and open in editor a switch to HEX view. Than I can see exactly what’s expected:

openHABian I’m running on the odroid n2+

Regarding connection via putty :
image

And now regarding rule and sending to serial port.
I created channel directly on the serial bridge :

and modify a rule :

then it’s sending :partying_face:

but code isn’t correct :

FF sent as 3F, F8 sent as 3F, E3 sent as 3F - don’t know why

EDIT :
changed a charset :

and communication is working. Received back data. Running via serial bridge.

Now it’s question how to make a processing hex to get a relevant data. Like when I will send a request for all temperatures, then calculate from answer temperatures and link to correct rooms.

3 Likes

:partying_face:

Huge win. I know its a first step but now you know it will all work.

Now first do the power switch. Get it to turn on and off with openHAB.

Then you will need openHAB to update when the power is turned off by any other means.

First win, but I need to know how to take a HEX answer from serial port and calculate a values.
Can I do it directly from the rule script (after send command) or …?

Yeah when the string item receives a command you can use that command to start a rule that will transform the data however you want it and put that data into items.