Base1Header would be used in building messages to the VISA network. I'm
not sure you want to be using this class. The constructor does not
expect two ip addresses - it wants VISA station numbers (6 digits).
> header.setLen(5);
This sets the length field *within* this header.
> System.out.println("length:"+header.getLength
> ()); length:22
> System.out.println
> ("ISOUtil.hexString"+ISOUtil.hexString(header.pack()));
> ISOUtil.hexString160102001B10E0E210E0E20000000000000000000000
^^^^
This is where your length ended up (22+5) = x'001b'
> System.out.println("header.getSource
> ():"+header.getSource()); header.getSource():
> 10E0E2
> System.out.println("header.getDestination
> ():"+header.getDestination()); header.getDestination():
> 10E0E2
>
> 1、why length is 22 what the usage of setLen()
A Base1Header is (normally) 22 bytes long. The setLen set the length
(in the header) of the whole message - including the header bytes.
> 2、why header.getSource() and header.getDestination() have the same
> value
These are being set from the start of your ip address - which are too
long for VISA source and destination - which is expecting 6 numeric
digits. In each case it takes "10.0.2" and makes some BCD.
This is just not a class - I think - you should be using.
>
> ================================================================
> BaseHeader baseheader = new BaseHeader();
> baseheader.setDestination("10.0.25.44");
> baseheader.setSource("10.0.25.50");
> System.out.println("@@@@"+ISOUtil.hexString(baseheader.pack
> ()));
>
> get Exception in thread "main" java.lang.NullPointerException errors?
Where *exactly* is the Exception and can you give the full Exception
stacktrace? I imagine something is not being set and so is null at time
of pack, the line on which the Exception occurs will give us that detail.
--
Mark