ABS SCPI Driver 0.2.0
ABS SCPI driver library
Loading...
Searching...
No Matches
UdpMcastDriver Class Referencefinal

UDP multicast driver for addressing multiple units at the same time. More...

#include <UdpMulticastDriver.h>

+ Inheritance diagram for UdpMcastDriver:
+ Collaboration diagram for UdpMcastDriver:

Detailed Description

UDP multicast driver for addressing multiple units at the same time.

Classes

struct  AddressedResponse
 Structure containing a response and the IP from which it was received. More...
 

Public Member Functions

 UdpMcastDriver ()
 CTOR.
 
 ~UdpMcastDriver ()
 DTOR.
 
ErrorCode Open (std::string_view interface_ip)
 Open a socket for communication with the ABS.
 
void Close () noexcept
 Close the socket.
 
ErrorCode Write (std::string_view data, unsigned int timeout_ms) const
 Send data over UDP multicast.
 
Result< std::string > ReadLine (unsigned int timeout_ms) const
 Read a line over UDP multicast.
 
Result< AddressedResponseReadLineFrom (unsigned int timeout_ms) const
 Read a line over UDP multicast, returning the line and the sender's IP address.
 
bool IsSendOnly () const
 Whether the device is send-only in the general case.
 
- Public Member Functions inherited from CommDriver
virtual void SetDeviceID (unsigned int id)
 Set the target device ID.
 
virtual unsigned int GetDeviceID () const
 Get the target device ID.
 

Member Function Documentation

◆ IsSendOnly()

bool IsSendOnly ( ) const
inlinevirtual

Whether the device is send-only in the general case.

Always true for multicast devices.

Returns
True.

Reimplemented from CommDriver.

◆ Open()

ErrorCode Open ( std::string_view  interface_ip)

Open a socket for communication with the ABS.

Parameters
[in]interface_ipaddress of local interface to bind to
Returns
An error code.

◆ ReadLine()

Result< std::string > ReadLine ( unsigned int  timeout_ms) const
virtual

Read a line over UDP multicast.

This is not a very useful function with multicast, as there may be many responses to one query. See ReadLineFrom() for a more useful function.

Parameters
[in]timeout_msread timeout in milliseconds
Returns
Result containing the line read or an error code.

Implements CommDriver.

◆ ReadLineFrom()

Result< AddressedResponse > ReadLineFrom ( unsigned int  timeout_ms) const

Read a line over UDP multicast, returning the line and the sender's IP address.

This is primarily intended to be used for device discovery.

Parameters
[in]timeout_msread timeout in milliseconds
Returns
Result containing the response or an error code.

◆ Write()

ErrorCode Write ( std::string_view  data,
unsigned int  timeout_ms 
) const
virtual

Send data over UDP multicast.

Parameters
[in]datadata to send
[in]timeout_mssend timeout in milliseconds
Returns
An error code.

Implements CommDriver.


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