Пример #1
0
  /**
   * Setup network protocol filter(s) to selectively restrict or limit messages received. Then purge
   * the PassThru device's receive buffer.
   *
   * @param channelId - handle to the open communications channel
   * @param mask - used to isolate the receive message header section(s) of interest
   * @param pattern - a message pattern to compare with the receive messages
   * @return the message filter ID to be used to later stop the filter
   */
  public int startPassMsgFilter(int channelId, byte mask, byte pattern) {
    PASSTHRU_MSG maskMsg = passThruMessage(mask);
    PASSTHRU_MSG patternMsg = passThruMessage(pattern);

    NativeLongByReference msgId = new NativeLongByReference();
    msgId.setValue(new NativeLong(0));
    NativeLong ret =
        lib.PassThruStartMsgFilter(
            new NativeLong(channelId),
            new NativeLong(Filter.PASS_FILTER.getValue()),
            maskMsg.getPointer(),
            patternMsg.getPointer(),
            null,
            msgId);
    if (ret.intValue() != Status.NOERROR.getValue())
      handleError("PassThruStartMsgFilter", ret.intValue());

    ret =
        lib.PassThruIoctl(
            new NativeLong(channelId),
            new NativeLong(IOCtl.CLEAR_RX_BUFFER.getValue()),
            null,
            null);
    if (ret.intValue() != Status.NOERROR.getValue())
      handleError("PassThruIoctl (CLEAR_RX_BUFFER)", ret.intValue());
    return msgId.getValue().intValue();
  }
Пример #2
0
 /**
  * Configures various PassThru parameters.
  *
  * @param channelId - handle to the open communications channel
  * @param items - values of multiple parameters can be set in an array of ConfigItem
  */
 public void setConfig(int channelId, ConfigItem... items) {
   if (items.length == 0) return;
   SCONFIG[] sConfigs = sConfigs(items);
   SCONFIG_LIST list = sConfigList(sConfigs);
   NativeLong ioctlID = new NativeLong();
   ioctlID.setValue(IOCtl.SET_CONFIG.getValue());
   NativeLong ret = lib.PassThruIoctl(new NativeLong(channelId), ioctlID, list.getPointer(), null);
   if (ret.intValue() != Status.NOERROR.getValue())
     handleError("PassThruIoctl (SET_CONFIG)", ret.intValue());
 }
Пример #3
0
 /**
  * Retrieve various PassThru configuration parameters.
  *
  * @param channelId - handle to the open communications channel
  * @param parameters - values of multiple parameters can be retrieved by setting an array of
  *     integer parameter IDs
  * @return an array of <b>ConfigItem</b>
  * @see ConfigItem
  */
 public ConfigItem[] getConfig(int channelId, int... parameters) {
   if (parameters.length == 0) return new ConfigItem[0];
   SCONFIG[] sConfigs = sConfigs(parameters);
   SCONFIG_LIST input = sConfigList(sConfigs);
   NativeLong ioctlID = new NativeLong();
   ioctlID.setValue(IOCtl.GET_CONFIG.getValue());
   NativeLong ret =
       lib.PassThruIoctl(new NativeLong(channelId), ioctlID, input.getPointer(), null);
   if (ret.intValue() != Status.NOERROR.getValue())
     handleError("PassThruIoctl (GET_CONFIG)", ret.intValue());
   return configItems(input);
 }
Пример #4
0
 /**
  * This function reads the battery voltage on pin 16 of the J2534 interface.
  *
  * @param channelId - handle to the open communications channel
  * @return battery voltage in VDC
  */
 public double getVbattery(int channelId) {
   NativeLongByReference vBatt = new NativeLongByReference();
   NativeLong ret =
       lib.PassThruIoctl(
           new NativeLong(channelId),
           new NativeLong(IOCtl.READ_VBATT.getValue()),
           null,
           vBatt.getPointer());
   if (ret.intValue() != Status.NOERROR.getValue()) handleError("PassThruIoctl", ret.intValue());
   LOGGER.trace("Ioctl result: " + vBatt.getValue().longValue());
   double response = vBatt.getValue().doubleValue() / 1000;
   return response;
 }
Пример #5
0
 /**
  * This function performs an ISO14230 fast initialization sequence.
  *
  * @param channelId - handle to the open communications channel
  * @param input - start message to be transmitted to the vehicle network
  * @return response - response upon a successful initialization
  */
 public byte[] fastInit(int channelId, byte[] input) {
   PASSTHRU_MSG inMsg = passThruMessage(input);
   PASSTHRU_MSG outMsg = passThruMessage();
   LOGGER.trace("Ioctl inMsg: " + toString(inMsg));
   NativeLong ret =
       lib.PassThruIoctl(
           new NativeLong(channelId),
           new NativeLong(IOCtl.FAST_INIT.value),
           inMsg.getPointer(),
           outMsg.getPointer());
   if (ret.intValue() != Status.NOERROR.getValue()) handleError("PassThruIoctl", ret.intValue());
   outMsg.read();
   LOGGER.trace("Ioctl outMsg: " + toString(outMsg));
   byte[] response = new byte[outMsg.dataSize.intValue()];
   arraycopy(outMsg.data, 0, response, 0, outMsg.dataSize.intValue());
   return response;
 }