VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::Serial_processor Class Reference

Serial ports I/O processor. More...

#include <serial_processor.h>

Inheritance diagram for ugcs::vsm::Serial_processor:
ugcs::vsm::File_processor ugcs::vsm::Request_context< is_processor > ugcs::vsm::Request_container

Classes

class  Stream
 Stream which represents opened serial port. More...
 

Public Types

typedef std::shared_ptr< Serial_processorPtr
 Pointer type.
 
typedef std::weak_ptr< Serial_processorWeak_ptr
 Pointer type.
 
- Public Types inherited from ugcs::vsm::File_processor
typedef std::shared_ptr< File_processorPtr
 Pointer type.
 
typedef std::weak_ptr< File_processorWeak_ptr
 Pointer type.
 
typedef ugcs::vsm::Param_exception< Exception_dummy_struct,> Exception
 
typedef ugcs::vsm::Derived_exception< Exception, Not_found_exception_dummy_structNot_found_exception
 Definition of a new exception type. More...
 
typedef ugcs::vsm::Derived_exception< Exception, Permission_denied_exception_dummy_structPermission_denied_exception
 Definition of a new exception type. More...
 
typedef ugcs::vsm::Derived_exception< Exception, Already_exists_exception_dummy_structAlready_exists_exception
 Definition of a new exception type. More...
 
- Public Types inherited from ugcs::vsm::Request_context< is_processor >
typedef std::shared_ptr< Request_contextPtr
 Pointer type.
 
typedef std::weak_ptr< Request_contextWeak_ptr
 Pointer type.
 
- Public Types inherited from ugcs::vsm::Request_container
enum  Type {
  Type::NONE = 0x0, Type::PROCESSOR = 0x1, Type::COMPLETION_CONTEXT = 0x2, Type::ANY = PROCESSOR | COMPLETION_CONTEXT,
  Type::TEMPORAL = 0x4, Type::TEMP_COMPLETION_CONTEXT = COMPLETION_CONTEXT | TEMPORAL
}
 Container type. More...
 
typedef std::shared_ptr< Request_containerPtr
 Pointer type.
 
typedef std::weak_ptr< Request_containerWeak_ptr
 Pointer type.
 

Public Member Functions

Stream::Ref Open (const std::string &port_name, const Stream::Mode &mode=Stream::Mode())
 Open serial port for communication. More...
 
- Public Member Functions inherited from ugcs::vsm::File_processor
Stream::Ref Open (const std::string &name, const std::string &mode, bool maintain_pos=true)
 Open file. More...
 
- Public Member Functions inherited from ugcs::vsm::Request_context< is_processor >
virtual Type Get_type () const override
 Get this container type. More...
 
- Public Member Functions inherited from ugcs::vsm::Request_container
 Request_container (const std::string &name, Request_waiter::Ptr waiter=Request_waiter::Create())
 Create container with default associated waiter. More...
 
bool Check_type (Type mask)
 Check if the container type conforms the specified characteristic mask. More...
 
void Submit_request (Request::Ptr request)
 Submit request to this container for further processing or notification handlers invocation. More...
 
void Submit_request_locked (Request::Ptr request, Request_waiter::Locker locker)
 The same as Submit_request, but with previously acquired lock of the associated waiter. More...
 
int Process_requests (int requests_limit=0)
 Process all currently queued requests. More...
 
int Process_requests (std::unique_lock< std::mutex > &lock, int requests_limit=0)
 Process all currently queued requests. More...
 
void Set_waiter (Request_waiter::Ptr waiter)
 Set request waiter associated with this container. More...
 
Request_waiter::Ptr Get_waiter () const
 Get request waiter associated with this container. More...
 
const std::string & Get_name ()
 Get the name of the container. More...
 
void Enable ()
 Enable the container. More...
 
void Disable ()
 Disable the container. More...
 
bool Is_enabled () const
 Check if the container is currently enabled. More...
 

Static Public Member Functions

template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
template<typename... Args>
static Ptr Get_instance (Args &&...args)
 Get global or create new processor instance. More...
 
static std::list< std::string > Enumerate_port_names ()
 Platform-specific enumeration of available serial ports. More...
 
- Static Public Member Functions inherited from ugcs::vsm::File_processor
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
template<typename... Args>
static Ptr Get_instance (Args &&...args)
 Get global or create new processor instance. More...
 
static FILE * Fopen_utf8 (const std::string &name, const std::string &mode)
 Platform independent method for opening a standard library file handle providing an UTF-8 encoded path and mode. More...
 
static bool Rename_utf8 (const std::string &old_name, const std::string &new_name)
 Platform independent method for renaming a file providing UTF-8 encoded paths. More...
 
static bool Remove_utf8 (const std::string &name)
 Platform independent method for removing a file providing UTF-8 encoded path.
 
static int Access_utf8 (const std::string &name, int mode)
 Platform independent method for checking file access permission providing UTF-8 file name. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Request_context< is_processor >
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 
- Static Public Member Functions inherited from ugcs::vsm::Request_container
template<typename... Args>
static Ptr Create (Args &&...args)
 Create an instance. More...
 

Static Public Attributes

static const uint8_t MAX_VMIN
 

Additional Inherited Members

- Protected Member Functions inherited from ugcs::vsm::File_processor
void Register_stream (File_processor::Stream::Ptr)
 Register opened stream in a processor. More...
 
- Protected Member Functions inherited from ugcs::vsm::Request_container
void Processing_loop ()
 Request processing loop implementation. More...
 
void Set_disabled ()
 Disable the container and notify its waiter. More...
 
virtual void On_wait_and_process ()
 Called when default processing loop want to wait for work and process it. More...
 
- Protected Attributes inherited from ugcs::vsm::Request_container
Request_waiter::Ptr waiter
 Waiter associated with this container. More...
 
std::list< Request::Ptrrequest_queue
 Queue of pending requests, i.e. More...
 

Detailed Description

Serial ports I/O processor.

Member Function Documentation

template<typename... Args>
static Ptr ugcs::vsm::Serial_processor::Create ( Args &&...  args)
inlinestatic

Create an instance.

static std::list<std::string> ugcs::vsm::Serial_processor::Enumerate_port_names ( )
static

Platform-specific enumeration of available serial ports.

This function returns the list of currently valid serial ports. It can change over time when usb cables get connected/disconnected

Returns
list of port names which can be used when calling Open().
template<typename... Args>
static Ptr ugcs::vsm::Serial_processor::Get_instance ( Args &&...  args)
inlinestatic

Get global or create new processor instance.

Stream::Ref ugcs::vsm::Serial_processor::Open ( const std::string &  port_name,
const Stream::Mode mode = Stream::Mode() 
)

Open serial port for communication.

Parameters
port_namePlatform-specific port name. Since on most OS'es serial ports can have arbitrary names, defined by vendor, user should specify necessary name. On Unix platform it is path to device, usually "/dev/ttyS<n>", on Windows it is typically names "COM<n>".
modeParameters for the port set up.
Returns
Opened stream for the port.
Exceptions
Invalid_param_exceptionif the specified mode contains invalid settings.
Not_found_exceptionif the specified path does not exist when it must exist based on provided opening mode.
Permission_denied_exceptionif there is insufficient permissions for file creation.
Exceptionin case of any other error returned by platform.

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