libpandac  0.0.0
A library designed for a comm.ai Panda.
vin.h
1 /*
2  Author: Matt Bunting
3  Copyright (c) 2020 Arizona Board of Regents
4  All rights reserved.
5 
6  Permission is hereby granted, without written agreement and without
7  license or royalty fees, to use, copy, modify, and distribute this
8  software and its documentation for any purpose, provided that the
9  above copyright notice and the following two paragraphs appear in
10  all copies of this software.
11 
12  IN NO EVENT SHALL THE ARIZONA BOARD OF REGENTS BE LIABLE TO ANY PARTY
13  FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14  ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15  IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
16  SUCH DAMAGE.
17 
18  THE ARIZONA BOARD OF REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER
21  IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION
22  TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 
24  */
25 
26 #ifndef VIN_H
27 #define VIN_H
28 
29 
30 #include <unistd.h> // usleep()
31 #include <cstring> // memcpy
32 
33 #include "panda.h"
34 //#include "panda/obd-pid.h"
35 
36 //#define CAN_FRAME_TYPE_MASK (0xF0)
37 //
38 namespace Panda {
39 //
40 //enum CanFrameTypes {
41 // CAN_FRAME_SINGLE = 0x00,
42 // CAN_FRAME_FIRST = 0x01,
43 // CAN_FRAME_CONSECUTIVE = 0x02,
44 // CAN_FRAME_FLOW_CONTROL = 0x03
45 //};
46 
47 
48 class VinReader : public CanListener {
49 public:
50 
51  VinReader();
52 
53  // Check this before using system time
54  bool vinRead();
55  const char* vinResult();
56  void setPandaHandler(Handler& handler);
57  void requestVin();
58 
59  /*
60  Will save the VIN to a file when discovered:
61  */
62  void saveToFile(const char* filename);
63 
64 private:
65  bool vinHasBeenRead;
66  Handler *mPandaHandler;
67 
68  int responseLength;
69  unsigned int assignedId;
70  char vin[17];
71  int vinLength; // this should always be 17
72 
73  bool shouldSaveToFile;
74  FILE* file;
75 
76  void sendFlowControl();
77  void newDataNotification( CanFrame* canFrame );
78 };
79 
80 }
81 
82 #endif
Definition: vin.h:48
A class that handles the Usb, GPS, and CAN data.
Definition: panda.h:50
Handles USB communication and parsing with a comma.ai Panda.
Definition: can.h:38
An abstract class for new data notifications for new CAN data.
Definition: can.h:63
Definition: candata.h:38