/* measure speed */
static int measure_data(int data_pid, ecu_data_t *ep)
{
  int rv;
  
  /* measure */
  rv = l3_do_j1979_rqst(global_l3_conn, 0x1, data_pid, 0x00,
      0x00, 0x00, 0x00, 0x00, (void *)0);
  if (rv < 0)
    return 0;
  
  /* data extraction */
  if (data_pid == RPM_PID)
    return (int)(RPM_DATA(ep->mode1_data) + .50);
  else if (data_pid == SPEED_PID)
    return (int)(SPEED_DATA(ep->mode1_data) + .50);
  else
    return DYNDATA_1(data_pid, 2, ep->mode1_data);
  
  return 0;
}
示例#2
0
// return <0 if error
static int measure_data(uint8_t data_pid, ecu_data *ep) {
	int rv;

	if (global_l3_conn == NULL) {
		fprintf(stderr, FLFMT "Error: there must be an active L3 connection!\n", FL);
		return DIAG_ERR_GENERAL;
	}
	/* measure */
	rv = l3_do_j1979_rqst(global_l3_conn, 0x1, data_pid, 0x00,
	  0x00, 0x00, 0x00, 0x00, (void *)&_RQST_HANDLE_NORMAL);
	if (rv < 0) {
		return rv;
	}

	/* data extraction */
	if (data_pid == RPM_PID) {
		return (int)(RPM_DATA(ep->mode1_data) + .50);
	}
	if (data_pid == SPEED_PID) {
		return (int)(SPEED_DATA(ep->mode1_data) + .50);
	}
	return DYNDATA_1(data_pid, 2, ep->mode1_data);
}