Menu

From Calimero to eibd library

2008-07-07
2013-05-28
  • Blr. Dev Tools

    Blr. Dev Tools - 2008-07-07

    Hi,

    I tested Calimero API for to send frames to a konnex installation, it works.
    Now I'm testing eibclient lib for to write my in c, but i don't have the same result.
    this is the Calimero code:

                CEMI_Connection tunnel = new CEMI_Connection(
                    new InetSocketAddress("192.168.1.201",
                        EIBNETIP_Constants.EIBNETIP_PORT_NUMBER),
                    new TunnellingConnectionType());
               
                PointPDUXlator dimVal = PDUXlatorList.getPointPDUXlator(
                    PDUXlatorList.TYPE_BOOLEAN[0],
                    PointPDUXlator_Boolean.DPT_BOOL[0]);

                dimVal.setServiceType(PointPDUXlator.A_GROUPVALUE_WRITE);
                dimVal.setASDUfromString("True");
           
                CEMI_L_DATA message0 = new CEMI_L_DATA(
                    CEMI_L_DATA.MC_L_DATAREQ,
                    new EIB_Address(),
                    new EIB_Address("0/0/1"),
                    dimVal.getAPDUByteArray()
                );
                tunnel.sendFrame(message0,CEMI_Connection.WAIT_FOR_CONFIRM);

    How to do the same using eibclient lib ?
    This is the code that I'm using im my app (only  for testing).

        EIBConnection *con = EIBSocketRemote("192.168.1.201",6720);
        argv[0] = "0x1";

        if(!con){
            printf("Connection Failed.\n");
            return (EXIT_FAILURE);
        }

        eibaddr_t dest = readgaddr ("0/0/2");
        uchar buf[255] = { 0, 0x80 };
        int len = readBlock(buf + 2, sizeof(buf)-2,1,argv);
       
        if (EIBOpenT_Group (con, dest, 1) == -1){
            printf("EIBOpenT_Group failed.\n");
            return (EXIT_FAILURE);
        }
      
        len = EIBSendAPDU(con, 2 + len, buf);
        if (len == -1){
            printf("Request failed.\n");
        }
      
        EIBClose(con);
        return (EXIT_SUCCESS);

    konnex installation recevie the message, but nothing happens.
    When I send the message with calimero the log is: packet received from 0.0.0 to 0/0/2 value 0 129
    When I send the message with eibdclient lib : packet received from 0.0.0 to 0/0/2 value 0 128 1

    somebody can help me to understand ?
    Thank you very much.

    Andrea

     
    • Martin Koegler

      Martin Koegler - 2008-07-08

      There are two frame formats:

      For datatypes up to 6 bits (groupswrite) and datatypes starting with 1 byte (groupwrite).

      Please look at groupswrite.c in this case.

      mfg Martin Kögler

       
    • Blr. Dev Tools

      Blr. Dev Tools - 2008-07-08

      Hi Martin,

      first of all thank you very much, this is my first project usign EIB, it was a emotion to turn on my first light !!! really thank you!
      Now I'll try to change others parameters, e.g. light intensity or brightness, wow I can't see !

      here the code for people that came from java using calimero. :]

          argv[0] = "0x0"; // change to 0x1 for to turn on the light
         
          EIBConnection *con = EIBSocketRemote("192.168.1.201",6720);
         
          if(!con){
              printf("Connection Failed.\n");
              return (EXIT_FAILURE);
          }
         
          eibaddr_t dest = readgaddr ("0/0/2"); // The group address
          uchar buf[3] = { 0, 0x80 };
         
          buf[1] |= readHex (argv[0]) & 0x3f;
          if (EIBOpenT_Group (con, dest, 1) == -1){
              printf("EIBOpenT_Group failed.\n");
              return (EXIT_FAILURE);
          }
         
          int len = EIBSendAPDU (con, 2, buf);
          if (len == -1){
              printf("Request failed.\n");
          }

          EIBClose(con);
          return (EXIT_SUCCESS);

      what is the meaning of 0x3f flag in line <buf[1] |= readHex (argv[0]) & 0x3f;> ?

      Andrea

       
      • Martin Koegler

        Martin Koegler - 2008-07-09

        The frame format only allows 6 data bits, so "AND 0x3f" masks out other bits.

        mfg Martin Kögler

         
    • Blr. Dev Tools

      Blr. Dev Tools - 2008-07-09

      Thanks Martin.

       

Log in to post a comment.