class rs232 : public chain

Used to present a unique serial interface to the world

Inheritance:


Public Methods

void Activities (void)
Looks for activities since the last call
void disable_watchdog (void)
Sniffing the interface is switched off
void enable_watchdog (void)
Sniffing the interface
bool receive (unsigned char *cptr, int n=1)
Receives a byte from the serial interface
bool Ring_Alarm (void)
Look for a ring alarm
rs232 (void)
The constructor
void RTS_toggle (void)
Toggle the RTS line
void rx_crc_init (void)
Cycle redundancy check prepare for receive
bool rx_ok (void)
Verify the received data
bool send (const unsigned char data)
Sends a byte through the interface
bool send_crc (void)
Sends the crc data of the transmitted bytes
bool Signal_Escape (void)
Returns the status if there was a special signal received
void tx_crc_init (void)
Cycle redundancy check prepare for transmit
~rs232 (void)
The destructor

Private Fields

int fd
File descriptor used as a handle
bool locked
Flag for signaling a lock file
unsigned short int rx_crc
Actual crc value for receive
unsigned short int tx_crc
Actual crc value for transmit

Private Methods

unsigned short int crc (unsigned short int crc_value, unsigned char data)
CRC function
void remove_lock (void)
Remove the lock file

Inherited from chain:

Protected Methods

bool add(unsigned char *data, int n=1)
int available(void)
bool read(unsigned char *data, int n=1)

Private Fields

unsigned char* cp
int cp_len
unsigned char* dcp
int dcp_len
chain* link

Private Methods

chain* reduce(void)

Inherited from sys_message:

Public Methods

void error(error_set id_num, char *text)
void message(char *text)
void warning(char *text)

Inherited from mail:


Inherited from memory:

Public Methods

void epilog_on(void)
void operator delete (void *pointer_to_bytes, size_t size)
void* operator new (size_t size)
long status(int id)

Documentation

Used to present a unique serial interface to the world. It is an object taylor made for BSD on NeXT. If it is necessary to port it elsewhere feel free to do so... NeXT handles some things different as the LOCK file and some other things. The only things handled are sending and receiving bytes through the serial I/O. What is an addition is the crc checksum on the fly. This could take place in the protocol but was left for the basics to ensure a reliable transmission. Something that is still missing in version 1.0 is a good treatment of a timeout and a reconnection of the line... What is also in this package is the signal handler serving a lot of different signals. What was added in version 1.1 is the method Activities, to remove all the nasty syslog stuff out of the signal handler. Nevertheless is this the right place for a future extension.

unsigned short int tx_crc
Actual crc value for transmit

unsigned short int rx_crc
Actual crc value for receive

int fd
File descriptor used as a handle

bool locked
Flag for signaling a lock file

unsigned short int crc(unsigned short int crc_value, unsigned char data)
CRC function. This method is a functional copy of the CRC checksum algorithm from the TI-99/4A of the good old days of Texas Instruments.

Returns:
The calculated crc checksum
Parameters:
crc_value - The crc value before taking data into account
data - The data to take into account

void remove_lock(void)
Remove the lock file. This method is an internal one and must be called before an error message.

void RTS_toggle(void)
Toggle the RTS line. If the RTS line is low, the line is risen high for 5 seconds, signaling the UPS to shutdown in the near future, if the UPS is on battery. Otherwise the UPS ignores the line toggle.

bool Ring_Alarm(void)
Look for a ring alarm. If the RNG line is set for an amount of time the method returns TRUE. If the battery is low, the alarm is set also.

Returns:
TRUE or FALSE, depends on the RNG time and the battery status

bool Signal_Escape(void)
Returns the status if there was a special signal received. The signals to look for are only various stop signals, which will normally terminate a program.

Returns:
TRUE or FALSE, depends on status of the received signals

void Activities(void)
Looks for activities since the last call. This method is used to show the activities without using things like syslog in the signal handler. It is therefore possible to have all the nasty syslog stuff in the sys_message object.

void tx_crc_init(void)
Cycle redundancy check prepare for transmit. This is the right place to feed the CRC with a special value for sending.

void rx_crc_init(void)
Cycle redundancy check prepare for receive. This is the right place to feed the CRC with a special value for receiving.

bool rx_ok(void)
Verify the received data. Simple check of the crc data to zero.

Returns:
TRUE or FALSE, depends on status of received data

bool send(const unsigned char data)
Sends a byte through the interface. Very evident function sending one single byte. Makes a CRC on the fly. This function is used to transmit data's.

Returns:
TRUE or FALSE, depends on the transmit status
Parameters:
data - The data to take into account

bool send_crc(void)
Sends the crc data of the transmitted bytes. This function is used to transmit the crc data's since last initialization.

Returns:
TRUE or FALSE, depends on the transmit status of the crc

bool receive(unsigned char *cptr, int n=1)
Receives a byte from the serial interface. Very evident function receiving one single byte. Makes a CRC on the fly. This function is used to receive data's. Optional parameter n is used as a minimum of requested bytes.

Returns:
TRUE on success, otherwise FALSE
Parameters:
cptr - The pointer where to write the received data
n - Number of desired bytes, default is one

void enable_watchdog(void)
Sniffing the interface. Enables the watch dog timer and have an eye on line breaks etc.

void disable_watchdog(void)
Sniffing the interface is switched off. Disables the watch dog timer and let things keep going.

rs232(void)
The constructor. Initialize the own data and look for the LOCK file. Tries to open the fixed device and disappear if no device is available, makes a lock file, initialize the signal hander and does other neat stuff.

~rs232(void)
The destructor. Release the device and and remove the LOCK file, switch off the signal handler.


This class has no child classes.
Author:
Henry Koplien
Version:
1.1 (first release 19. November 1998, last edit 29. November 1998)

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de