mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-24 01:23:45 +08:00
502cc665e0
* pigeon abstraction layer * Fix string literals * more generic pigeon class * add TTYpigon * nicer tty error handling * close tty fd on pigeon delete * pigeon receive return std::string * use sizeof * max receive size to prevent infinite loop * remove namespace * add unistd include for usleep * fix is pigeon * Handle tty error in opening * fix printing binary strings with dump.py * fix pigeon build on macos * Handle errors seperately Co-authored-by: Comma Device <device@comma.ai>
44 lines
867 B
C++
44 lines
867 B
C++
#pragma once
|
|
#include <string>
|
|
#include <termios.h>
|
|
|
|
|
|
#include "panda.h"
|
|
|
|
class Pigeon {
|
|
public:
|
|
static Pigeon* connect(Panda * p);
|
|
static Pigeon* connect(const char * tty);
|
|
virtual ~Pigeon(){};
|
|
|
|
void init();
|
|
virtual void set_baud(int baud) = 0;
|
|
virtual void send(std::string s) = 0;
|
|
virtual std::string receive() = 0;
|
|
virtual void set_power(bool power) = 0;
|
|
};
|
|
|
|
class PandaPigeon : public Pigeon {
|
|
Panda * panda = NULL;
|
|
public:
|
|
~PandaPigeon();
|
|
void connect(Panda * p);
|
|
void set_baud(int baud);
|
|
void send(std::string s);
|
|
std::string receive();
|
|
void set_power(bool power);
|
|
};
|
|
|
|
|
|
class TTYPigeon : public Pigeon {
|
|
int pigeon_tty_fd = -1;
|
|
struct termios pigeon_tty;
|
|
public:
|
|
~TTYPigeon();
|
|
void connect(const char* tty);
|
|
void set_baud(int baud);
|
|
void send(std::string s);
|
|
std::string receive();
|
|
void set_power(bool power);
|
|
};
|