Menu

Creating and modifying Analog Input objects

mmenard
2020-07-29
2020-07-30
  • mmenard

    mmenard - 2020-07-29

    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"><meta content="Microsoft Word 15 (filtered medium)" name="Generator"><style><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri",sans-serif;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;} div.WordSection1 {page:WordSection1;} --></style>

    Hello everyone!

    <o:p> </o:p>

    Im currently working on a project where I need to create virtual objects in a gateway. Those virtual objects will be use when my  gateway will dynamically connect ZigBee thermostats. I’m working on Linux Ubuntu 20.04.

    <o:p> </o:p>

    Using the gateway example in apps/gateway/main from stack 1.0.0, I think I’ve been able to create virtual Analog_Input objects with a simple Analog_Input_Init() (please correct me if it is not the proper way to create AI objects). I’m currently trying to modify the present value of one of the Analog_Input object by using the function Analog_Input_Present_Value_Set(Object_Instance, Value_Test). Even if Value_Test is<o:p></o:p>

    equal to 100.0 (float) the object present value always stays to 0.0 (when I do : printf( "Value is %f ", Analog_Input_Present_Value(Object_Instance)). <o:p></o:p>

    <o:p> </o:p>

    I’ve done some test in the terminal and I’m confident that the virtual objects are simply identified as 1,2,3,4,5,… So this function Analog_Input_Present_Value_Set(1, 100.0) should attributes 100.0 to object 1.<o:p></o:p>

    <o:p> </o:p>

    Interestingly enough,  I’ve put printf() in the function Analog_Input_Present_Value_Set and the value is automatically reset to 0.0 (the first line of the function). I checked the value of my second parameter just before I call this function and it is a equal to 100.0.<o:p></o:p>

    <o:p> </o:p>

    Also, I was trying to install a proper debugger in VS Code. It is working with a simple helloworld.cpp file, but I struggle to make it work with the BACnet gateway project. I don’t know if you guys have a better setup than me?<o:p></o:p>

    <o:p> </o:p>

    Thank you,<o:p></o:p>

    <o:p> </o:p>

    Maxime<o:p></o:p>

    <o:p> </o:p>

    <o:p> </o:p>

     
  • mmenard

    mmenard - 2020-07-30

    Hi everyone,

    Don't lose your time on this problem, I finally found that when I declare : float Value_Test =100.0; and I pass this variable in Analog_Input_Present_Value_Set(1, Value_Test)
    I give the function a DOUBLE instead of a FLOAT type. When I do Analog_Input_Present_Value_Set(1, 100.0F) the function works as expected. I found it by passing the structure of an Analog_Input object with Analog_Input_Present_Value_Set(1, AI_Descr[index].Present_Value).

    Best Regards,

    Maxime

     
  • mmenard

    mmenard - 2020-07-30

    Hi everyone,

    Finally none of what I said is true, the only problem was that I forget to include ai.h that's all! Before that, gcc gave me warnings and build the project like everything is fine. Now I get less warning and less problems!

    Also, about the debugging in VS Code I added "CFLAGS += -g -O0" at the top of the main makefile found in the stack folder. With this, I'm able to debug properly.

    Maxime

     

Log in to post a comment.