Skip to content
Snippets Groups Projects
Commit 4ab8c2a6 authored by Alessandro Simovic's avatar Alessandro Simovic Committed by Beat Küng
Browse files

tap_esc: made _uart_fd a class member

parent 64aab8a6
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,6 @@
* This driver connects to TAP ESCs via serial.
*/
static int _uart_fd = -1; //todo:refactor in to class
class TAP_ESC : public device::CDev, public ModuleParams
{
public:
......@@ -96,13 +95,14 @@ public:
MODE_5CAP,
MODE_6CAP,
};
TAP_ESC(int channels_count);
TAP_ESC(int channels_count, int uart_fd);
virtual ~TAP_ESC();
virtual int init();
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg);
void cycle();
private:
int _uart_fd;
static const uint8_t device_mux_map[TAP_ESC_MAX_MOTOR_NUM];
static const uint8_t device_dir_map[TAP_ESC_MAX_MOTOR_NUM];
......@@ -173,9 +173,10 @@ TAP_ESC *tap_esc = nullptr;
# define TAP_ESC_DEVICE_PATH "/dev/tap_esc"
TAP_ESC::TAP_ESC(int channels_count):
TAP_ESC::TAP_ESC(int channels_count, int uart_fd):
CDev("tap_esc", TAP_ESC_DEVICE_PATH),
ModuleParams(nullptr),
_uart_fd(uart_fd),
_is_armed(false),
_poll_fds_num(0),
_mode(MODE_4PWM), //FIXME: what is this mode used for???
......@@ -937,6 +938,7 @@ namespace tap_esc_drv
volatile bool _task_should_exit = false; // flag indicating if tap_esc task should exit
static int _uart_fd = -1;
static char _device[32] = {};
static bool _is_running = false; // flag indicating if tap_esc app is running
static px4_task_t _task_handle = -1; // handle to the task main thread
......@@ -967,7 +969,7 @@ int tap_esc_start(void)
if (tap_esc == nullptr) {
tap_esc = new TAP_ESC(_supported_channel_count);
tap_esc = new TAP_ESC(_supported_channel_count, _uart_fd);
if (tap_esc == nullptr) {
ret = -ENOMEM;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment