@Override
  protected byte[] getBytes() {
    final List<Byte> byteList =
        new ArrayList<>(Bytes.asList(COPSMsgParser.shortToBytes(protocol.getValue())));
    byteList.add(tosOverwrite);
    byteList.add(tosMask);
    byteList.addAll(Bytes.asList(srcAddress.getAddress()));
    byteList.addAll(Bytes.asList(dstAddress.getAddress()));
    byteList.addAll(Bytes.asList(COPSMsgParser.shortToBytes(srcPort)));
    byteList.addAll(Bytes.asList(COPSMsgParser.shortToBytes(dstPort)));
    byteList.add(priority);

    // reserved padding
    byteList.addAll(Bytes.asList((byte) 0, (byte) 0, (byte) 0));

    return Bytes.toArray(byteList);
  }
Example #2
0
 static {
   for (Protocol s : EnumSet.allOf(Protocol.class)) lookup.put(s.getValue(), s);
 }
Example #3
0
 /**
  * Constructor declaration
  *
  * @param protocol - <b>Protocol</b> enum specified by J2534-1
  * @param library - native library of the J2534 device
  * @exception J2534Exception on various non-zero return status
  */
 public J2534Impl(Protocol protocol, String library) {
   this.protocolID = new NativeLong(protocol.getValue());
   lib = new J2534_v0404(library);
 }