#ifndef GSERIAL_H
#define GSERIAL_H

#include "piserial.h"

class PIGSerial: public PISerial {
	PIIODEVICE(PIGSerial, "gser");
public:
	PIGSerial();
	~PIGSerial();
	
protected:
	PIString constructFullPathDevice() const override;
	void configureFromFullPathDevice(const PIString & full_path) override;
	bool openDevice() override;
	bool closeDevice() override;
	ssize_t writeDevice(const void * data, ssize_t max_size) override;
	void _write(const PIByteArray & ba);

	EVENT_HANDLER(void, tickWrite);

	PITimer timer_wq;
	PIQueue<PIByteArray> write_q;
	PIMutex mutex_q;
	int gpio_num, gpio_read_value, gpio_write_value;

};

REGISTER_DEVICE(PIGSerial)

#endif // GSERIAL_H
