Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19199

Unable to start PLC4X route in camel-plc4x

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.20.2
    • 3.20.4, 3.21.0, 4.0-M3, 4.0.0
    • None
    • None
    • Camel core version : 3.20.2 Camel-PLC4X version : 3.20.2

      IDE - Eclipse, OS - Windows 10, Java 11

    • Unknown

    Description

      I am using ModbusPal to create the Virtual modbus.

      I am using the endpoint URI as:

       

      plc4x:modbus-tcp://localhost:502?unitId=1&dataType=holding-register&addresses=1

      Following is the screenshot of Modbus holding registers:

      But when starting camel context it throws NullPointerException.

       

      java.lang.NullPointerException
          at org.apache.camel.component.plc4x.Plc4XConsumer.startUnTriggered(Plc4XConsumer.java:89)
          at org.apache.camel.component.plc4x.Plc4XConsumer.doStart(Plc4XConsumer.java:81)
          at org.apache.camel.support.service.BaseService.start(BaseService.java:119) 

      I debugged it and found the problem is with this line in PLC4XConsumer line 89:

       

      for (Map.Entry<String, Object> tag : tags.entrySet()) {

       

      Here tags are null, so it might be that I am not configuring the endpoint correctly.

      So, I tried by configuring the endpoint by creating an instance of Plc4XEndpoint and then configuring the tags there, it works like:

      Map<String, Object> map = new HashMap<>();
                  map.put("value-1", "holding-register:1");
                  
                  Plc4XEndpoint plc4xEndpoint = new Plc4XEndpoint("plc4x:modbus-tcp://localhost:502",
                          getContext().getComponent("plc4x"));
                  plc4xEndpoint.setTags(map);
                  from(plc4xEndpoint).log("value : ${body}"); 

      But why it is not working if I configure the endpoint as just String?

      Note:

      I tried with below endpoint and it is also not working:

      plc4x:modbus-tcp://localhost:502?tags={unitId=1&dataType=holding-register&addresses=1} 

       

      Attachments

        1. image-2023-03-27-11-14-56-624.png
          118 kB
          Ghazanfar Ali

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              mdanish98 Ghazanfar Ali
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: