class ugcs::vsm::Serial_processor

Overview

Serial ports I/O processor. More…

#include <serial_processor.h>

class Serial_processor: public ugcs::vsm::File_processor
{
public:
    // typedefs

    typedef std::shared_ptr<Serial_processor> Ptr;
    typedef std::weak_ptr<Serial_processor> Weak_ptr;

    // classes

    class Stream;

    // fields

    static const uint8_t MAX_VMIN;

    // methods

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename... Args>
    static Ptr Get_instance(Args&&... args);

    static std::list<std::string> Enumerate_port_names();
    Stream::Ref Open(const std::string& port_name, const Stream::Mode& mode = Stream::Mode());
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<Request_container> Ptr;
    typedef std::weak_ptr<Request_container> Weak_ptr;
    typedef std::shared_ptr<Request_context> Ptr;
    typedef std::weak_ptr<Request_context> Weak_ptr;
    typedef std::shared_ptr<File_processor> Ptr;
    typedef std::weak_ptr<File_processor> Weak_ptr;
    typedef ugcs::vsm::Param_exception<Exception_dummy_struct,> Exception;
    typedef ugcs::vsm::Derived_exception<Exception, Not_found_exception_dummy_struct> Not_found_exception;
    typedef ugcs::vsm::Derived_exception<Exception, Permission_denied_exception_dummy_struct> Permission_denied_exception;
    typedef ugcs::vsm::Derived_exception<Exception, Already_exists_exception_dummy_struct> Already_exists_exception;

    // enums

    enum Type;

    // structs

    struct Already_exists_exception_dummy_struct;
    struct Exception_dummy_struct;
    struct Not_found_exception_dummy_struct;
    struct Permission_denied_exception_dummy_struct;

    // classes

    class Request;
    class Request_waiter;
    class Native_controller;
    class Stream;

    // methods

    template <typename... Args>
    static Ptr Create(Args&&... args);

    virtual Type Get_type() const;
    bool Check_type(Type mask);
    void Submit_request(Request::Ptr request);
    void Submit_request_locked(Request::Ptr request, Request_waiter::Locker locker);
    int Process_requests(int requests_limit = 0);
    int Process_requests(std::unique_lock<std::mutex>& lock, int requests_limit = 0);
    void Set_waiter(Request_waiter::Ptr waiter);
    Request_waiter::Ptr Get_waiter() const;
    const std::string& Get_name();
    void Enable();
    void Disable();
    bool Is_enabled() const;

    template <typename... Args>
    static Ptr Create(Args&&... args);

    virtual Type Get_type() const;
    Request_container(const std::string& name, Request_waiter::Ptr waiter = Request_waiter::Create());

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename... Args>
    static Ptr Get_instance(Args&&... args);

    static FILE* Fopen_utf8(const std::string& name, const std::string& mode);
    static bool Rename_utf8(const std::string& old_name, const std::string& new_name);
    static bool Remove_utf8(const std::string& name);
    static int Access_utf8(const std::string& name, int mode);
    Stream::Ref Open(const std::string& name, const std::string& mode, bool maintain_pos = true);

Detailed Documentation

Serial ports I/O processor.

Typedefs

typedef std::shared_ptr<Serial_processor> Ptr

Pointer type.

typedef std::weak_ptr<Serial_processor> Weak_ptr

Pointer type.

Methods

template <typename... Args>
static Ptr Create(Args&&... args)

Create an instance.

template <typename... Args>
static Ptr Get_instance(Args&&... args)

Get global or create new processor instance.

static std::list<std::string> Enumerate_port_names()

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().

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

Open serial port for communication.

Parameters:

port_name

Platform-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>”.

mode

Parameters for the port set up.

Invalid_param_exception

if the specified mode contains invalid settings.

Not_found_exception

if the specified path does not exist when it must exist based on provided opening mode.

Permission_denied_exception

if there is insufficient permissions for file creation.

Exception

in case of any other error returned by platform.

Returns:

Opened stream for the port.