Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Hex code - RS232 / RS485


Question

Posted

I've need to send hex code from Fibaro HC2 to Global Cache itach rs232 / 485.

The hex code is: 7F F2 FA 01 00 00 AE 49 FA FE FD 06 58

 

Using Global Cache's iTest, I can control my equipment as needed using the above hex code. However, entering the above into Fibaro, by way of a virtual device does not enable control. I have tried to add the "0x0D0x0A" string to the end, and that also does not enable control.

Can anyone suggest what is needed to get this to work?

 

Thanks,

12 answers to this question

Recommended Posts

  • 0
Posted

try the following:

 

tcpSocket = Net.FTcpSocket(ip, port);
tcpSocket:setReadTimeout(2000);

 

tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58));

or

tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58, 0x0d));

or

tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58, 0x0d, 0x0A));

  • 0
  • Inquirer
  • Posted

    try the following:

     

    tcpSocket = Net.FTcpSocket(ip, port);

    tcpSocket:setReadTimeout(2000);

     

    tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58));

    or

    tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58, 0x0d));

    or

    tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58, 0x0d, 0x0A));

    Thanks - I have now tried each of these without success.

     

    On Global Cache's iTest, I have the following setup:

     

    Serial 1 - port 4999

    Ip Address - ip of itach

    Command string - I can enter this, and have it work, in either Hex or Mixed mode.

     

    When I click send, the process works, and I have the correct response from my equipment.

     

    In Fibaro, I have the following setup:

    Virtual device.

    Ip Address = itach ip

    Port = itach port

    Button string:

    tcpSocket = Net.FTcpSocket(itach ip, itach port);

    tcpSocket:setReadTimeout(2000);

    tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58));

     

    It just seems Fibaro cant / wont send the message, or .

     

     

    Any other thoughts?

     

    Cheers

    • 0
    Posted

    What do you mean with "Button string:"?  Did you set it to "Lua code" when trying?

    • 0
  • Inquirer
  • Posted

    What do you mean with "Button string:"?  Did you set it to "Lua code" when trying?

    I just mean I created a button, and in the advanced tab, under the button label and ID, I entered the data in the black box, and set the option to "String", not LUA code.

    • 0
    Posted

    Can you try "lua code", it is lua code that I provided.

    • 0
  • Inquirer
  • Posted

    Thanks for your help - got it now

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> And it works... I had to make a slight change to your code.

     

     

    I got a malformed number error, next to the ip address, so I know have the code as below:

    tcpSocket = Net.FTcpSocket("itach ip", itach port);
    tcpSocket:setReadTimeout(2000);
    tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFD, 0x06, 0x58));

     

    I then got the following error for line 3:

    ')' expected near ';'

     

    So now I have:

    tcpSocket:write(string.char(tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFE, 0x06, 0x59))));

     

    No more errors.

     

    So, full code is:

    tcpSocket = Net.FTcpSocket("192.x.x.x",4999);
    tcpSocket:setReadTimeout(2000);
    tcpSocket:write(string.char(tcpSocket:write(string.char(0x7F, 0xF2, 0xFA, 0x01, 0x00, 0x00, 0xAE, 0x49, 0xFA, 0xFE, 0xFE, 0x06, 0x59))));

     

    Thank you very much for your help

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    • Like 1
    • 0
    Posted

    Dear Experts,

     

    my GC iTach Flex is located outside my network at a place with changing IP address.
    I am using DYN DNS to have a host name that always points to the iTach Flex port 4998.

     

    My control device is Fibaro's Home Center 2.

     

    Following this instruction

    Please login or register to see this link.

      and knowing my IP I could successfully use the sendir function with a virtual device. All great. All works. iTach Flex is fantastic.

    But the problem is that the IP is changed every day by the service provider.

    Therefore I can not use the IP but would need to use the DYN DNS host name.

    And Fibro only allows to enter the IP address and port number in the SEND STRING field.

    What I would need is to use a LUA code that send the string to my host.

    Above example ""tcpSocket:write" seamse to work with HEX only.B

     

    Is there a way that I can send with "tcpSocket:write" as well the sendir code like the example below?

     

    Example code TV Power on that I entered in a VD as string: sendir,1:1,1,40201,3,1,96,24,48,24,24,24,48,24,24,24,48,24,24,24,24,24,48,24,24,24,24,24,24,24,24,10140x0D0x0A

     

    It would be great if you could help!

     

    Best regards,
    Alex

    • 0
    Posted

    You could try this, don't know if this can work with a url..... but worth trying

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

     

    Just to mention: I replaced 0x0D0x0A to \r in this piece of code

    Please login or register to see this code.

    • 0
    Posted

    Dear Boerremk, thank you very much!

    Works perfect

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    • 0
    Posted

    I was having NO JOY with my itach flex sending commands via Home Centre 2 (both through LUA code and the normal string config) and thought that there was an issue with the CR character I was trying to send.  Commands worked perfectly from iTest, but wouldn't work from HC2.

     

    I finally figured out after reading countless entries across various forums that sometimes HC2 simply needs a reboot after configuring a virtual device before that device starts behaving properly.

     

    Give it a try if you're having problems - it definitely worked for me.

    • 0
    Posted
    On 2017/1/17 at 3:28 PM, fibarojiang said:

    你好,我可以帮你做一个485信号反馈可以接收虚拟设备?我有一个由485控制的电源窗口,现在我可以实现单向控制,不意味着我可以正确地知道它是否是打开或关闭状态,可以帮助我修改我的代码? 我想知道如果我真的打开需要检测485通讯的返回值实现,“平开打开”

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

    • 0
    Posted
    10 hours ago, fibarojiang said:

     

    Hi @fibarojiang

    That last post came through as Chinese 

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...