• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Problem with Read Property Request

    BACnet4J general discussion
    2
    18
    7.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      decora
      last edited by

      Hi, i have a problem with ReadPropertyRequest. When i run my Java program, eclipse return an exception, precisely:

      
      Exception in thread "main" java.lang.NullPointerException
      	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:216)
      	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:432)
      	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:422)
      	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:415)
      	at Prova_B4J.main(Prova_B4J.java:143)
      
      

      My program is this:

      
      public class Prova_B4J {
      	
      	private Prova_B4J(){}
      	
      	public static void main(String[] args) throws IOException, InterruptedException, BACnetException, BACnetServiceException{
      		
      		LocalDevice localDevice = new LocalDevice(1969,"172.16.4.14", "172.16.4.40");
      		localDevice.setPort(0xBAC0);
      		localDevice.getConfiguration().setProperty(PropertyIdentifier.segmentationSupported,Segmentation.noSegmentation);
      		RemoteDevice remoteDevice = new RemoteDevice(0, new Address(new byte[] { (byte) 172, (byte) 16, 4, (byte) 14 },0xBAC0 ), null);
      		localDevice.addRemoteDevice(remoteDevice);
      		
      			localDevice.getEventHandler().addListener(new DeviceEventListener(){  
      				  
      	            public void listenerException(Throwable e) {  
      	                System.out.println("DiscoveryTest listenerException");
      	                e.printStackTrace();
      	            }  
      	  
      	            public void iAmReceived(RemoteDevice d) {  
      	                System.out.println("DiscoveryTest iAmReceived");  
      	                synchronized (this) {  
      	                    this.notifyAll();  
      	                }  
      	            }  
      	  
      	            public boolean allowPropertyWrite(BACnetObject obj, PropertyValue pv) {  
      	                System.out.println("DiscoveryTest allowPropertyWrite");  
      	                return true;  
      	            }  
      	  
      	            public void propertyWritten(BACnetObject obj, PropertyValue pv) {  
      	                System.out.println("DiscoveryTest propertyWritten");  
      	            }  
      	  
      	            public void iHaveReceived(RemoteDevice d, RemoteObject o) {  
      	                System.out.println("DiscoveryTest iHaveReceived");  
      	            }  
      	  
      	            public void covNotificationReceived(UnsignedInteger subscriberProcessIdentifier, RemoteDevice initiatingDevice, ObjectIdentifier monitoredObjectIdentifier, UnsignedInteger timeRemaining, SequenceOf<PropertyValue> listOfValues) {  
      	                System.out.println("DiscoveryTest covNotificationReceived");  
      	            }  
      	  
      	            public void eventNotificationReceived(UnsignedInteger processIdentifier, RemoteDevice initiatingDevice, ObjectIdentifier eventObjectIdentifier, TimeStamp timeStamp, UnsignedInteger notificationClass, UnsignedInteger priority, EventType eventType, CharacterString messageText, NotifyType notifyType, Boolean ackRequired, EventState fromState, EventState toState, NotificationParameters eventValues) {  
      	                System.out.println("DiscoveryTest eventNotificationReceived");  
      	            }  
      	  
      	            public void textMessageReceived(RemoteDevice textMessageSourceDevice, Choice messageClass, MessagePriority messagePriority, CharacterString message) {  
      	                System.out.println("DiscoveryTest textMessageReceived");  
      	            }  
      	  
      	            public void privateTransferReceived(UnsignedInteger vendorId, UnsignedInteger serviceNumber, Encodable serviceParameters) {  
      	                System.out.println("DiscoveryTest privateTransferReceived");  
      	            }
      
      				@Override
      				public void eventNotificationReceived(UnsignedInteger arg0,
      						RemoteDevice arg1, ObjectIdentifier arg2,
      						TimeStamp arg3, UnsignedInteger arg4,
      						UnsignedInteger arg5, EventType arg6,
      						CharacterString arg7, NotifyType arg8,
      						com.serotonin.bacnet4j.type.primitive.Boolean arg9,
      						EventState arg10, EventState arg11,
      						NotificationParameters arg12) {
      					// TODO Auto-generated method stub
      					System.out.println("DiscoveryTest eventNotificationReceived");
      				}
      
      				@Override
      				public void reinitializeDevice(ReinitializedStateOfDevice arg0) {
      					// TODO Auto-generated method stub
      					
      				}
      
      				@Override
      				public void synchronizeTime(DateTime arg0, boolean arg1) {
      					// TODO Auto-generated method stub
      					
      				}  
      	        });  
      			
      	        localDevice.initialize();  
      	        System.out.println("Sono pronto...");
      	        
      	        ReadPropertyRequest RPR= new ReadPropertyRequest(new ObjectIdentifier(ObjectType.analogOutput,11),new PropertyIdentifier(85));
      	        localDevice.send(remoteDevice,RPR);
      	        	        
      	    }
      	
      }
      
      

      What is the problem?
      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler
        last edited by

        Did you initialize the local device?

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • D
          decora
          last edited by

          Yes, I did...look at row 82...i used localDevice.initialize();

          PS: About the device that should receive the ReadPropertyRequest, I have simulated it with VTS

          1 Reply Last reply Reply Quote 0
          • M
            mlohbihler
            last edited by

            The line numbers in the stack trace aren't lining up with my code. Are you using the latest version?

            Best regards,
            Matthew

            1 Reply Last reply Reply Quote 0
            • D
              decora
              last edited by

              Yes, i'm using bacnet4j 1.2 downloaded form sourceforge project

              1 Reply Last reply Reply Quote 0
              • M
                mlohbihler
                last edited by

                For fun, try this one...

                Attachment: download link

                Best regards,
                Matthew

                1 Reply Last reply Reply Quote 0
                • D
                  decora
                  last edited by

                  I tried using your library, and indeed it is different from mine, since I also had to add the commons-lang3.3.1.jar at the project to make it work.
                  Despite this, However, the problem is not solved :-(

                  1 Reply Last reply Reply Quote 0
                  • M
                    mlohbihler
                    last edited by

                    Ok, but can you post the stack trace? I assume the line numbers are different now.

                    Best regards,
                    Matthew

                    1 Reply Last reply Reply Quote 0
                    • D
                      decora
                      last edited by

                      Yes, the line numbers are different.
                      This is the stack trace:

                      
                      Exception in thread "main" java.lang.NullPointerException
                      	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:226)
                      	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:480)
                      	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:470)
                      	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:463)
                      	at Prova_B4J.main(Prova_B4J.java:143)
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • M
                        mlohbihler
                        last edited by

                        Your remote device has a segmentationSupported value of null. Normally you wouldn't instantiate your own RemoteDevice objects, BTW. An IAm (resulting from a WhoIs broadcast) is the typical means of instantiation. A "manual" way to get remote devices is to use the LocalDevice.findRemoteDevice method.

                        Best regards,
                        Matthew

                        1 Reply Last reply Reply Quote 0
                        • D
                          decora
                          last edited by

                          I tried your solutions, but there are other problems.
                          If I use:

                          
                          remoteDevice=localDevice.findRemoteDevice( new Address(new byte[] { (byte) 192, (byte) 168, (byte) 1, (byte) 112 },0xBAC0 ), null, 1);
                          
                          

                          eclipse return this exception:

                          
                          Exception in thread "main" com.serotonin.bacnet4j.exception.BACnetException: java.lang.NullPointerException
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.sendImpl(IpMessageControl.java:377)
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:302)
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:248)
                          	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:480)
                          	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:470)
                          	at com.serotonin.bacnet4j.LocalDevice.findRemoteDevice(LocalDevice.java:1047)
                          	at Prova_B4J_2.main(Prova_B4J_2.java:57)
                          Caused by: java.lang.NullPointerException
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.sendImpl(IpMessageControl.java:374)
                          	... 6 more
                          
                          

                          If I use:

                          
                          localDevice.sendBroadcast(0xBAC0,new WhoIsRequest(null,null));
                          
                          

                          eclipse return:

                          
                          Exception in thread "main" com.serotonin.bacnet4j.exception.BACnetException: java.lang.NullPointerException
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.sendImpl(IpMessageControl.java:377)
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.sendBroadcast(IpMessageControl.java:359)
                          	at com.serotonin.bacnet4j.LocalDevice.sendBroadcast(LocalDevice.java:520)
                          	at Prova_B4J_2.main(Prova_B4J_2.java:59)
                          Caused by: java.lang.NullPointerException
                          	at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.sendImpl(IpMessageControl.java:374)
                          	... 3 more
                          
                          
                          1 Reply Last reply Reply Quote 0
                          • M
                            mlohbihler
                            last edited by

                            Did you initialize the local device before sending those requests?

                            Best regards,
                            Matthew

                            1 Reply Last reply Reply Quote 0
                            • D
                              decora
                              last edited by

                              Perfect!! Thnak you very, but very very very much for the help!

                              I have only another questions...If I send an I-am message from VTS to instantiate the remote device in my java program, I have no problem ... but if I send it from another java program (always based on bacnet4j), eclipse returns this exception when I send the ReadPropertyRequest:

                              
                              Exception in thread "main" com.serotonin.bacnet4j.exception.ErrorAPDUException: ErrorAPDU(choice=5, errorClass=Object, errorCode=Unknown object)
                              	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:489)
                              	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:470)
                              	at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:463)
                              	at Prova_B4J_2.main(Prova_B4J_2.java:106)
                              
                              
                              1 Reply Last reply Reply Quote 0
                              • M
                                mlohbihler
                                last edited by

                                Your BACnet4J device does not have the object you are looking for. You need to create a BACnet object with the correct properties, and then add it to the local device.

                                Best regards,
                                Matthew

                                1 Reply Last reply Reply Quote 0
                                • D
                                  decora
                                  last edited by

                                  Thank you mlohbihler! You have been my salvation!

                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    mlohbihler
                                    last edited by

                                    Glad to help. Buy a license. :)

                                    Best regards,
                                    Matthew

                                    1 Reply Last reply Reply Quote 0
                                    • D
                                      decora
                                      last edited by

                                      :wink:

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post