PX4 Firmware
PX4 Autopilot Software http://px4.io
DevCommon Class Reference
Inheritance diagram for DevCommon:
Collaboration diagram for DevCommon:

Public Types

enum  Operation { Read, Write }
 

Public Member Functions

 DevCommon (const char *device_path)
 
virtual ~DevCommon ()
 
virtual int ioctl (struct file *filp, int cmd, unsigned long arg)
 
virtual int open (file *filp)
 
virtual int close (file *filp)
 
- Public Member Functions inherited from cdev::CDev
 CDev (const char *devname)
 Constructor. More...
 
 CDev (const CDev &)=delete
 
CDevoperator= (const CDev &)=delete
 
 CDev (CDev &&)=delete
 
CDevoperator= (CDev &&)=delete
 
virtual ~CDev ()
 
virtual int init ()
 
virtual int open (file_t *filep)
 Handle an open of the device. More...
 
virtual int close (file_t *filep)
 Handle a close of the device. More...
 
virtual ssize_t read (file_t *filep, char *buffer, size_t buflen)
 Perform a read from the device. More...
 
virtual ssize_t write (file_t *filep, const char *buffer, size_t buflen)
 Perform a write to the device. More...
 
virtual off_t seek (file_t *filep, off_t offset, int whence)
 Perform a logical seek operation on the device. More...
 
virtual int ioctl (file_t *filep, int cmd, unsigned long arg)
 Perform an ioctl operation on the device. More...
 
virtual int poll (file_t *filep, px4_pollfd_struct_t *fds, bool setup)
 Perform a poll setup/teardown operation. More...
 
const char * get_devname () const
 Get the device name. More...
 

Protected Types

enum  ParserState : uint8_t { ParserState::Idle = 0, ParserState::GotLength }
 

Protected Member Functions

virtual pollevent_t poll_state (struct file *filp)
 
void lock (enum Operation op)
 
void unlock (enum Operation op)
 
- Protected Member Functions inherited from cdev::CDev
virtual pollevent_t poll_state (file_t *filep)
 Check the current state of the device for poll events from the perspective of the file. More...
 
virtual void poll_notify (pollevent_t events)
 Report new poll events. More...
 
virtual void poll_notify_one (px4_pollfd_struct_t *fds, pollevent_t events)
 Internal implementation of poll_notify. More...
 
virtual int open_first (file_t *filep)
 Notification of the first open. More...
 
virtual int close_last (file_t *filep)
 Notification of the last close. More...
 
virtual int register_class_devname (const char *class_devname)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
virtual int unregister_class_devname (const char *class_devname, unsigned class_instance)
 Register a class device name, automatically adding device class instance suffix if need be. More...
 
void lock ()
 Take the driver lock. More...
 
void unlock ()
 Release the driver lock. More...
 
int unregister_driver_and_memory ()
 First, unregisters the driver. More...
 

Protected Attributes

int _fd = -1
 
uint16_t _packet_len
 
ParserState _parser_state = ParserState::Idle
 
bool _had_data = false
 whether poll() returned available data More...
 
- Protected Attributes inherited from cdev::CDev
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Additional Inherited Members

- Static Protected Attributes inherited from cdev::CDev
static const px4_file_operations_t fops = {}
 Pointer to the default cdev file operations table; useful for registering clone devices etc. More...
 

Detailed Description

Definition at line 119 of file protocol_splitter.cpp.

Member Enumeration Documentation

◆ Operation

Enumerator
Read 
Write 

Definition at line 130 of file protocol_splitter.cpp.

◆ ParserState

enum DevCommon::ParserState : uint8_t
strongprotected
Enumerator
Idle 
GotLength 

Definition at line 158 of file protocol_splitter.cpp.

Constructor & Destructor Documentation

◆ DevCommon()

DevCommon::DevCommon ( const char *  device_path)

Definition at line 169 of file protocol_splitter.cpp.

◆ ~DevCommon()

DevCommon::~DevCommon ( )
virtual

Definition at line 174 of file protocol_splitter.cpp.

References _fd, and close().

Here is the call graph for this function:

Member Function Documentation

◆ close()

int DevCommon::close ( file filp)
virtual

Definition at line 200 of file protocol_splitter.cpp.

References _fd.

Referenced by ~DevCommon().

Here is the caller graph for this function:

◆ ioctl()

int DevCommon::ioctl ( struct file filp,
int  cmd,
unsigned long  arg 
)
virtual

Definition at line 181 of file protocol_splitter.cpp.

References _fd.

Referenced by Mavlink2Dev::write(), and RtpsDev::write().

Here is the caller graph for this function:

◆ lock()

void DevCommon::lock ( enum Operation  op)
inlineprotected

Definition at line 137 of file protocol_splitter.cpp.

◆ open()

int DevCommon::open ( file filp)
virtual

Definition at line 193 of file protocol_splitter.cpp.

References _fd.

◆ poll_state()

pollevent_t DevCommon::poll_state ( struct file filp)
protectedvirtual

Definition at line 209 of file protocol_splitter.cpp.

References _fd, _had_data, and cdev::CDev::poll().

Here is the call graph for this function:

◆ unlock()

void DevCommon::unlock ( enum Operation  op)
inlineprotected

Definition at line 149 of file protocol_splitter.cpp.

Member Data Documentation

◆ _fd

int DevCommon::_fd = -1
protected

◆ _had_data

bool DevCommon::_had_data = false
protected

whether poll() returned available data

Definition at line 164 of file protocol_splitter.cpp.

Referenced by poll_state(), Mavlink2Dev::read(), and RtpsDev::read().

◆ _packet_len

uint16_t DevCommon::_packet_len
protected

Definition at line 157 of file protocol_splitter.cpp.

Referenced by Mavlink2Dev::write(), and RtpsDev::write().

◆ _parser_state

ParserState DevCommon::_parser_state = ParserState::Idle
protected

Definition at line 162 of file protocol_splitter.cpp.

Referenced by Mavlink2Dev::write(), and RtpsDev::write().


The documentation for this class was generated from the following file: