libpandac  0.0.0
A library designed for a comm.ai Panda.
Classes | Typedefs | Enumerations | Functions
Panda Namespace Reference

Handles USB communication and parsing with a comma.ai Panda. More...

Classes

struct  _CanFrame
 
struct  _GpsData
 
struct  _GpsInfo
 
struct  _GpsMotion
 
struct  _GpsPosition
 
struct  _GpsQuality
 
struct  _GpsSatellite
 
class  Can
 A class that handles the CAN data. More...
 
class  CanListener
 An abstract class for new data notifications for new CAN data. More...
 
class  Gps
 A class that handles the GPS data. More...
 
class  GpsListener
 An abstract class for new data notifications for new GPS data. More...
 
class  Handler
 A class that handles the Usb, GPS, and CAN data. More...
 
class  ObdPidRequest
 
class  SetSystemTimeObserver
 
class  ToyotaHandler
 A threaded interface class that handles sending contorl commands to a Panda via a Panda::Handler. More...
 
class  Usb
 
class  UsbListener
 
class  VinReader
 

Typedefs

typedef struct Panda::_CanFrame CanFrame
 
typedef struct Panda::_GpsPosition GpsPosition
 
typedef struct Panda::_GpsMotion GpsMotion
 
typedef struct Panda::_GpsQuality GpsQuality
 
typedef struct Panda::_GpsSatellite GpsSatellite
 
typedef struct Panda::_GpsInfo GpsInfo
 
typedef struct Panda::_GpsData GpsData
 

Enumerations

enum  CanFrameTypes { CAN_FRAME_SINGLE = 0x00, CAN_FRAME_FIRST = 0x01, CAN_FRAME_CONSECUTIVE = 0x02, CAN_FRAME_FLOW_CONTROL = 0x03 }
 
enum  ObdPidModes { OBD_PID_SERVICE_CURRENT_DATA = 0x01, OBD_PID_SERVICE_FREEZE_FRAME_DATA = 0x02, OBD_PID_SERVICE_VEHICLE_INFO = 0x09 }
 
enum  ObdPidVehicleInfo { OBD_PID_VEHICLE_INFO_VIN_COUNT = 0x01, OBD_PID_VEHICLE_INFO_VIN = 0x02 }
 
enum  UsbMode { MODE_SYNCHRONOUS, MODE_ASYNCHRONOUS, MODE_ISOCHRONOUS }
 

Functions

CanFrame bufferToCanFrame (char *buffer, int bufferLength)
 Converts a buffer from Panda to CanFrame data. More...
 
void canFrameToBuffer (CanFrame &frame, unsigned char *buffer)
 Converts a CanFrame into a buffer for sending to the Panda. More...
 
CanFrame buildLkasHud (bool lkaAlert, unsigned char leftLane, unsigned char rightLane, bool barrier, bool twoBeeps, bool repeatedBeeps)
 Constructs the LKAS_HUS command that works on a Toyota RAV4. More...
 
CanFrame buildSteeringLKA (unsigned char count, int16_t steerTorque, bool steerRequest, unsigned char lkaState)
 Constructs the STEERING_LKA command, used for sending steering torque. More...
 
CanFrame buildACC_CONTROL (double acc, bool permitBraking, bool releaseStandstill, bool miniCar, bool cancelRequest)
 Constructs the ACC_CONTROL command, used for sending cruise cntrol accelerations. More...
 
CanFrame buildTRACK_B_1 (unsigned char count)
 Constructs the TRACK_B_1 command, needed to fake adaptive cruise controller operation. Note that there could be more things to fake in this command, but for use of ACC_CONTROL this command is intercepted to prevent run-time faults of the ACC. More...
 
CanFrame buildPCM_CRUISE_2 (unsigned char SET_SPEED)
 Unused by ToyotaHandler. Also untested.
 
CanFrame buildDSU_CRUISE (unsigned char SET_SPEED)
 Unused by ToyotaHandler. Also untested.
 
uint8_t toyotaChecksum (Panda::CanFrame &frame)
 Computes particular checksums within the CAN message, and is not the CRC for the CAN frame itself. More...
 
void printFrame (Panda::CanFrame frame)
 This funciton is helpful for debugging but should either not live in toyota.h or shoul dbe removed: More...
 
const char * safetyModelToString (int safetyModel)
 
const char * carHarnessStatusToString (int car_harness_status)
 
const char * faultStatusToString (int fault_status)
 
std::string faultsToString (int faults)
 
const char * usbPowerModeToString (int usb_power_mode)
 
void printPandaHealth (const PandaHealth &health)
 

Detailed Description

Handles USB communication and parsing with a comma.ai Panda.

Function Documentation

CanFrame Panda::bufferToCanFrame ( char *  buffer,
int  bufferLength 
)

Converts a buffer from Panda to CanFrame data.

Parameters
bufferThe buffer from the Panda read.
bufferLengthThe number of bytes in the buffer. Should be 8-16
Returns
A constructed CanFrame, populated witht eh bufffer data
CanFrame Panda::buildACC_CONTROL ( double  acc,
bool  permitBraking,
bool  releaseStandstill,
bool  miniCar,
bool  cancelRequest 
)

Constructs the ACC_CONTROL command, used for sending cruise cntrol accelerations.

Parameters
permitBrakingUnsure of purpose outside of name. Should be 1 when sending control commands, perhaps.
releaseStandstillUnsure of purpose outside of name. Should be 1 when sending control commands when car has been commanded to stop and is desired to let the car continue to be controlle dout of a stop, perhaps.
miniCarWill display the "Mini Car" on the HUD, but only works when the cruise control is activated and operating.
cancelRequestWill cancel the cruise controller, informing the driver to regain control of the vehicle.
Returns
A constructed ACC_CONTROL CanFrame.
CanFrame Panda::buildLkasHud ( bool  lkaAlert,
unsigned char  leftLane,
unsigned char  rightLane,
bool  barrier,
bool  twoBeeps,
bool  repeatedBeeps 
)

Constructs the LKAS_HUS command that works on a Toyota RAV4.

Parameters
lkaAlertWill invoke a "Please grab steering wheel" notification on the car HUD.
leftlaneCan be 0-3, and will show different left lane visuals on the HUD.
rightlaneCan be 0-3, and will show different right lane visuals on the HUD.
barrierWill display a barrier on the right and left lanes.
twoBeepsWill cause a single two-beep audible alert in the car. If called too frequently then it may not trigger.
repeatedBeepsWill cause a continuous audible beeping alert.
Returns
A constructed LKA_HUD CanFrame
CanFrame Panda::buildSteeringLKA ( unsigned char  count,
int16_t  steerTorque,
bool  steerRequest,
unsigned char  lkaState 
)

Constructs the STEERING_LKA command, used for sending steering torque.

Parameters
countThis needs to increase by 1 on each send, probably for error checking.
steerTorqueIn unknown units, but is valid from -1500:1500.
steerRequestShould be set to 1 when a steering torque is sent. This is shown by CAN reading of the built-in LKA.
lkaStateUnknown, labeled in the DBC. Stays 0 based on CAN data.
Returns
A constructed STEERING_LKA CanFrame.
CanFrame Panda::buildTRACK_B_1 ( unsigned char  count)

Constructs the TRACK_B_1 command, needed to fake adaptive cruise controller operation. Note that there could be more things to fake in this command, but for use of ACC_CONTROL this command is intercepted to prevent run-time faults of the ACC.

Parameters
countNeeds to be increment on each call. It may be only 6 bits long even though the DBC states 8-bits. See ToyotaHandler for how this is handeled.
Returns
A constructed TRACK_B_1 CanFrame.
void Panda::canFrameToBuffer ( CanFrame frame,
unsigned char *  buffer 
)

Converts a CanFrame into a buffer for sending to the Panda.

Parameters
frameThe CAN frame of data to be sent
bufferThe array of data to be sent. Should be 16 bytes in length.
void Panda::printFrame ( Panda::CanFrame  frame)

This funciton is helpful for debugging but should either not live in toyota.h or shoul dbe removed:

Parameters
frameThe frame to be printed to the console
uint8_t Panda::toyotaChecksum ( Panda::CanFrame frame)

Computes particular checksums within the CAN message, and is not the CRC for the CAN frame itself.

Parameters
frameThe frame for the checksum to be computer
Returns
The resulting checksum for the CAN frame.