|
Open Model Railroad Network (OpenMRN)
|
Base class for railcom drivers. More...
#include <Railcom.hxx>
Public Member Functions | |
| RailcomDriverBase (const char *name) | |
| Constructor. | |
| void | os_interrupt_handler () |
| Implementation of the interrupt handler running at the kernel interrupt priority. | |
| RailcomDriverBase (const char *name) | |
| Constructor. | |
| void | os_interrupt_handler () |
| Implementation of the interrupt handler running at the kernel interrupt priority. | |
Public Member Functions inherited from RailcomDriver | |
| virtual void | feedback_sample ()=0 |
| Call to the driver for sampling the current sensors. | |
| virtual void | start_cutout ()=0 |
| Instructs the driver that the railcom cutout is starting now. | |
| virtual void | middle_cutout ()=0 |
| Notifies the driver that the railcom cutout has reached the middle point, i.e., the first window is passed and the second window is starting. | |
| virtual void | end_cutout ()=0 |
| Instructs the driver that the railcom cutout is over now. | |
| virtual void | no_cutout ()=0 |
| Called instead of start/mid/end-cutout at the end of the current packet if there was no cutout requested. | |
| virtual void | send_ch1 (const DCCFeedback *ch1_pkt) |
| Specifies what packet should be sent for the channel1 cutout. | |
| virtual void | send_ch2 (const DCCFeedback *ch2_pkt) |
| Specifies what packet should be sent for the channel2 cutout. | |
Protected Member Functions | |
| dcc::Feedback * | alloc_new_packet (uint8_t channel) |
| Takes a new empty packet at the front of the queue, fills in feedback key and channel information. | |
| void | add_sample (int sample) |
| Adds a sample for a preamble bit. | |
| dcc::Feedback * | alloc_new_packet (uint8_t channel) |
| Takes a new empty packet at the front of the queue, fills in feedback key and channel information. | |
| void | add_sample (int sample) |
| Adds a sample for a preamble bit. | |
Protected Attributes | |
| Notifiable * | readableNotifiable_ |
| Notify this when we have data in our buffers. | |
| FixedQueue< dcc::Feedback, HW::Q_SIZE > | feedbackQueue_ |
| The packets we have read so far. | |
| uint32_t | feedbackKey_ |
| Stores the key for the next packets to read. | |
| dcc::Feedback * | returnedPackets_ [HW::CHANNEL_COUNT] |
| Stores pointers to packets we are filling right now, one for each channel. | |
Private Member Functions | |
| ssize_t | write (File *, const void *, size_t) OVERRIDE |
| Write to a file or device. | |
| ssize_t | read (File *file, void *buf, size_t count) OVERRIDE |
| Read from a file or device. | |
| void | flush_buffers () OVERRIDE |
| Instructs the device driver to drop all TX and RX queues. | |
| int | ioctl (File *file, unsigned long int key, unsigned long data) override |
| Request an ioctl transaction. | |
| void | set_feedback_key (uint32_t key) OVERRIDE |
| Specifies the feedback key to write into the received railcom data packets. | |
| virtual void | int_set_pending (unsigned int_nr)=0 |
| Sets a given software interrupt pending. | |
| ssize_t | write (File *, const void *, size_t) OVERRIDE |
| Write to a file or device. | |
| ssize_t | read (File *file, void *buf, size_t count) OVERRIDE |
| Read from a file or device. | |
| void | flush_buffers () OVERRIDE |
| Instructs the device driver to drop all TX and RX queues. | |
| int | ioctl (File *file, unsigned long int key, unsigned long data) override |
| Request an ioctl transaction. | |
| void | set_feedback_key (uint32_t key) OVERRIDE |
| Specifies the feedback key to write into the received railcom data packets. | |
Private Member Functions inherited from Node | |
| Node (const char *name) | |
| Constructor. | |
| virtual | ~Node () |
| Destructor. | |
| virtual void | enable ()=0 |
| This will be called once when reference-count goes from 0 to positive. | |
| virtual void | disable ()=0 |
| This will be called when reference count goes from non-zero to 0. | |
| int | open (File *, const char *, int, int) OVERRIDE |
| Open method. | |
| int | close (File *) OVERRIDE |
| Close method. | |
| virtual int | fstat (File *file, struct stat *stat) override |
| Get the status information of a file or device. | |
Private Member Functions inherited from Device | |
| Device (const char *name) | |
| Constructor. | |
| virtual | ~Device () |
| Destructor. | |
Private Member Functions inherited from FileIO | |
| FileIO (const char *name) | |
| Constructor. | |
| virtual | ~FileIO () |
| Destructor. | |
| virtual off_t | lseek (File *f, off_t offset, int whence) |
| Seek method. | |
| virtual int | fcntl (File *file, int cmd, unsigned long data) |
| Manipulate a file descriptor. | |
| virtual bool | select (File *file, int mode) |
| Device select method. | |
Additional Inherited Members | |
Static Private Member Functions inherited from Device | |
| static int | open (struct _reent *reent, const char *path, int flags, int mode) |
| Open a file or device. | |
| static int | close (struct _reent *reent, int fd) |
| Close a file or device. | |
| static int | stat (struct _reent *reent, const char *path, struct stat *stat) |
| Get the status information of a file or device. | |
| static int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, long long timeout) |
| POSIX select(). | |
| static void | select_clear () |
| Clears the current thread's select bits. | |
| static void | select_insert (SelectInfo *info) |
| Add client to list of clients needing woken. | |
| static void | select_wakeup (SelectInfo *info) |
| Wakeup the list of clients needing woken. | |
| static void | select_wakeup_from_isr (SelectInfo *info, int *woken) |
| Wakeup the list of clients needing woken. | |
Static Private Member Functions inherited from FileIO | |
| static ssize_t | read (struct _reent *reent, int fd, void *buf, size_t count) |
| Read from a file or device. | |
| static ssize_t | write (struct _reent *reent, int fd, const void *buf, size_t count) |
| Write to a file or device. | |
| static _off_t | lseek (struct _reent *reent, int fd, _off_t offset, int whence) |
| Change the offset index of a file or device. | |
| static int | fstat (struct _reent *reent, int fd, struct stat *stat) |
| Get the status information of a file or device. | |
| static int | ioctl (int fd, unsigned long int key, unsigned long data) |
| Request and ioctl transaction. | |
| static int | fcntl (int fd, int cmd, unsigned long data) |
| Manipulate a file descriptor. | |
| static bool | is_device (int fd) |
| Test if the file descriptor belongs to a device. | |
| static int | fd_alloc (void) |
| Allocate a free file descriptor. | |
| static void | fd_free (int fd) |
| Free up a file descriptor. | |
| static File * | file_lookup (int fd) |
| Looks up a reference to a File corresponding to a given file descriptor. | |
| static int | fd_lookup (File *file) |
| Looks up a file descriptor corresponding to a given File reference. | |
Private Attributes inherited from Node | |
| OSMutex | lock_ |
| protects internal structures. | |
| mode_t | mode_ |
| File open mode, such as O_NONBLOCK. | |
| unsigned int | references_ |
| number of open references | |
Private Attributes inherited from FileIO | |
| const char * | name |
| device name | |
Static Private Attributes inherited from FileIO | |
| static const unsigned int | numOpenFiles = 20 |
| static File | files [] |
| File descriptor pool. | |
| static OSMutex | mutex |
| mutual exclusion for fileio | |
Base class for railcom drivers.
Base class for railcom driver implementations.
Ideally this base class should be non-specific to the hardwsre or the TivaWare driver library.
Definition at line 132 of file Railcom.hxx.
|
inline |
Constructor.
| name | is the device node (e.g. "/dev/railcom0"). |
Definition at line 136 of file Railcom.hxx.
|
inline |
Definition at line 145 of file Railcom.hxx.
|
inline |
Constructor.
| name | is the device node (e.g. "/dev/railcom0"). |
Definition at line 127 of file RailcomImpl.hxx.
|
inline |
Definition at line 134 of file RailcomImpl.hxx.
|
inlineprotected |
Adds a sample for a preamble bit.
| sample | is the next sample to return to the application layer (usually a bitmask setting which channels are active). |
Definition at line 261 of file Railcom.hxx.
|
inlineprotected |
Adds a sample for a preamble bit.
| sample | is the next sample to return to the application layer (usually a bitmask setting which channels are active). |
Definition at line 253 of file RailcomImpl.hxx.
|
inlineprotected |
Takes a new empty packet at the front of the queue, fills in feedback key and channel information.
| channel | is which channel to set the packet for. |
Definition at line 245 of file Railcom.hxx.
|
inlineprotected |
Takes a new empty packet at the front of the queue, fills in feedback key and channel information.
| channel | is which channel to set the packet for. |
Definition at line 237 of file RailcomImpl.hxx.
|
inlineprivatevirtual |
Instructs the device driver to drop all TX and RX queues.
This is called after disable() still under the device lock.
Implements Node.
Definition at line 173 of file Railcom.hxx.
|
inlineprivatevirtual |
Instructs the device driver to drop all TX and RX queues.
This is called after disable() still under the device lock.
Implements Node.
Definition at line 165 of file RailcomImpl.hxx.
|
privatepure virtual |
Sets a given software interrupt pending.
| int_nr | interrupt number (will be HW::OS_INTERRUPT) |
Implemented in Stm32RailcomDriver< HW >, and TivaRailcomDriver< HW >.
|
inlineoverrideprivatevirtual |
Request an ioctl transaction.
| file | file reference for this device |
| key | ioctl key |
| data | key data |
Reimplemented from FileIO.
Definition at line 182 of file Railcom.hxx.
|
inlineoverrideprivatevirtual |
Request an ioctl transaction.
| file | file reference for this device |
| key | ioctl key |
| data | key data |
Reimplemented from FileIO.
Definition at line 174 of file RailcomImpl.hxx.
|
inline |
Implementation of the interrupt handler running at the kernel interrupt priority.
Call this function from the hardware interrupt handler.
Definition at line 219 of file Railcom.hxx.
|
inline |
Implementation of the interrupt handler running at the kernel interrupt priority.
Call this function from the hardware interrupt handler.
Definition at line 211 of file RailcomImpl.hxx.
|
inlineprivatevirtual |
Read from a file or device.
| file | file reference for this device |
| buf | location to place read data |
| count | number of bytes to read |
Implements FileIO.
Definition at line 157 of file Railcom.hxx.
|
inlineprivatevirtual |
Read from a file or device.
| file | file reference for this device |
| buf | location to place read data |
| count | number of bytes to read |
Implements FileIO.
Definition at line 149 of file RailcomImpl.hxx.
|
inlineprivatevirtual |
Specifies the feedback key to write into the received railcom data packets.
This feedback key is used by the application layer to correlate the stream of DCC packets to the stream of Railcom packets. This method shall be called before start_cutout. The feedback key set here is used until this method is called again.
| key | is the new feedback key. |
Implements RailcomDriver.
Definition at line 234 of file Railcom.hxx.
|
inlineprivatevirtual |
Specifies the feedback key to write into the received railcom data packets.
This feedback key is used by the application layer to correlate the stream of DCC packets to the stream of Railcom packets. This method shall be called before start_cutout. The feedback key set here is used until this method is called again.
| key | is the new feedback key. |
Implements RailcomDriver.
Definition at line 226 of file RailcomImpl.hxx.
|
inlineprivatevirtual |
Write to a file or device.
| file | file reference for this device |
| buf | location to find write data |
| count | number of bytes to write |
Implements FileIO.
Definition at line 151 of file Railcom.hxx.
|
inlineprivatevirtual |
Write to a file or device.
| file | file reference for this device |
| buf | location to find write data |
| count | number of bytes to write |
Implements FileIO.
Definition at line 143 of file RailcomImpl.hxx.
|
protected |
Stores the key for the next packets to read.
Definition at line 282 of file Railcom.hxx.
|
protected |
The packets we have read so far.
Definition at line 280 of file Railcom.hxx.
|
protected |
Notify this when we have data in our buffers.
Definition at line 278 of file Railcom.hxx.
|
protected |
Stores pointers to packets we are filling right now, one for each channel.
Definition at line 285 of file Railcom.hxx.