INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
serialconnectivity.h
1 /*
2  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3  * http://gearbox.sf.net/
4  * Copyright (c) 2004-2010 Michael Moser
5  *
6  * This distribution is licensed to you under the terms described in
7  * the LICENSE file included in this distribution.
8  *
9  */
10 namespace gbxserialacfr{
11  class Serial;
12 }
13 
14 // test connectivity to a [serial] device at a [baudrate];
15 // Assumes that you can figure out a [challenge] (command ...) to
16 // which the device will answer with a unique [ack] in [timeOutMsec] milliseconds.
17 // If [successThresh] or more [challenge]es are answered by an [ack]
18 //
19 // Limitations: amount of data expected before timeOutMsec should be
20 // reasonably small
21 //
22 // returns true for Success; false for failure
23 namespace gbxnovatelutilacfr{
24 bool testConnectivity(
25  std::string &challenge,
26  std::string &ack,
27  gbxserialacfr::Serial& serial,
28  int timeOutMsec,
29  int numTry,
30  int successThresh,
31  int baudrate);
32 
33 // send a [challenge] (command ...) to
34 // which the device will answer with a unique [ack] in [timeOutMsec] milliseconds.
35 //
36 // Limitations: amount of data expected before timeOutMsec should be
37 // reasonably small
38 //
39 // returns true for Success (i.e. ack received in time),
40 // false for failure, in case of failure errorResponse contains the reply from the receiver
41 bool sendCmdWaitForResponse(
42  std::string &challenge,
43  std::string &ack,
44  std::string &errorResponse,
45  gbxserialacfr::Serial& serial,
46  int timeOutMsec);
47 }
virtual ssize_t WriteString(const char *const buffer)
Write a string to the port.
Definition: port.cpp:331
int bytesAvailable()
Returns the number of bytes available for reading (non-blocking).
Definition: serial.cpp:704
virtual void Flush()=0
Flush the port's input and output buffers, discarding all data.
virtual ssize_t ReadLine(char *const buffer, size_t count)
Read a new-line terminated string of data.
Definition: port.cpp:201
Exception thrown by Serial.
Definition: serial.h:22
virtual void Open()=0
Open the port.
virtual ssize_t BytesAvailableWait()=0
Get the number of bytes waiting after blocking for the timeout.
Simple serial port interface.
Definition: gbxnovatelacfr/driver.h:21
Exception thrown by the Port class and its derivatives.
Definition: flexiport.h:54
virtual ssize_t ReadStringUntil(std::string &buffer, char terminator)
Read a string until the specified termination character is received.
Definition: port.cpp:160
virtual ssize_t ReadString(std::string &buffer)
Read a string.
Definition: port.cpp:72
int writeString(const char *buf)
Definition: serial.cpp:757
void flush()
Definition: serial.cpp:825
virtual ssize_t BytesAvailable()=0
Get the number of bytes waiting to be read at the port. Returns immediatly.
int read(void *buf, int count)
Definition: serial.cpp:585
FLEXIPORT_EXPORT Port * CreatePort(std::string options)
Overloaded factory function. Accepts options as a string.
Encapsulates a serial port.
Definition: serial.h:43
virtual ssize_t ReadUntil(void *const buffer, size_t count, uint8_t terminator)
Read data until a specified termination byte is received.
Definition: port.cpp:115
virtual ssize_t Read(void *const buffer, size_t count)=0
Read from the port.
virtual ssize_t ReadFull(void *const buffer, size_t count)=0
Read the requested quantity of data from the port.
virtual ssize_t Write(const void *const buffer, size_t count)=0
Write data to the port.
Base Port class.
Definition: port.h:79
virtual std::string GetStatus() const
Get the status of the port (type, device, etc).
Definition: port.cpp:352
void setBaudRate(int baud)
Sets the baud rate. Flushes any data.
Definition: serial.cpp:455
 

Generated for GearBox by  doxygen 1.4.5