hCommTCPSocket

Superclass:
hComm
Declared In:

Introduction

a class that defines a TCP interface to a Hyperion Instrument



Member Functions

close
connect
hCommTCPSocket(int, std :: string, std :: string)
hCommTCPSocket(std :: string, int, int)
read_data
set_timeout
write_data
~hCommTCPSocket

close


public

int close();
Discussion

close the communication channel to the instrument.


connect


public

int connect();
Discussion

open a communication channel and establish a connection. Throws HyperionException on error.


hCommTCPSocket(int, std :: string, std :: string)


public

hCommTCPSocket( int sockfd, std::string command = "", std::string argument = "");
Parameters
sockfd

A valid socket file descriptor.

command

A command to be immediately executed.

argument

Argument to the command to be executed.

Discussion

Constructor for hCommTCPSocket. This version takes an already initialized and valid socket number and binds the comm object to that. It can also optionally execute a command.


hCommTCPSocket(std :: string, int, int)


public

hCommTCPSocket( std::string ipAddress, int port = H_CMD_PORT, int timeout = H_DEFAULT_TIMEOUT);
Parameters
ipAddress

The TCP/IPv4 address of the instrument in #.#.#.# format.

port

The port number to connect to.

timeout

The defaul timeout for all TCP communications.

Discussion

Constructor for hCommTCPSocket


read_data


private

int read_data( uint32_t numBytes, uint8_t data[]);
Parameters
numBytes

the number of Bytes to be returned.

data

the data returned as an array of bytes.

Return Value

returns the number of bytes read, or -1 if there is an error

Discussion

Read raw data back from a communication channel.


set_timeout


public

int set_timeout( int timeout);
Parameters
timeout

The timeout value in milliseconds

Discussion

set the timeout value in milliseconds for the specified channel. Throws HyperionException on error.


write_data


private

ssize_t write_data( const char *data, size_t dataCount);
Parameters
data

Data buffer to write.

dataCount

number of dataBytes to write out

Return Value

Returns number of bytes written if successful, -1 otherwise

Discussion

Write raw data to a communication channel


~hCommTCPSocket


public

~hCommTCPSocket();
Discussion

Destructor for hCommTCPSocket