46 #if ! WITH_ESD_CAN && ! WITH_PEAK_CAN 47 # error "At least support for ESD-CAN or PEAK-CAN must be enabled to compile cancat" 64 char const*
__help__ =
"Send data from command line via ESD or PEAK CAN and display replies until CTRL-C is pressed.";
66 char const*
__author__ =
"Dirk Osswald: dirk.osswald@de.schunk.com";
67 char const*
__url__ =
"http://www.schunk.com";
68 char const*
__version__ =
"$Id: cancat.cpp 9739 2013-02-04 15:39:29Z Osswald2 $";
74 int main(
int argc,
char** argv )
78 cSDHOptions options(
"general sdhcom_common sdhcom_esdcan sdhcom_peakcan sdhcom_cancommon" );
110 char const* sep =
"";
113 strncat( buffer, argv[
optind++ ], 511 );
114 strncat( buffer, sep, 511 );
117 strncat( buffer,
"\r\n", 511 );
119 dbg <<
"Sending String \"" << buffer <<
"\" via CAN\n";
122 canserial->
write( buffer, strlen( buffer ) );
127 if ( 1 == canserial->
Read( &reply, 1,
long(options.
timeout*1E6),
false ) )
128 printf(
"%c", reply );
136 cerr <<
"cancat main(): Caught exception from SDHLibrary: " << e->
what() <<
". Giving up!\n";
141 cerr <<
"cancat main(): caught unexpected exception!\n";
unsigned long can_baudrate
int Parse(int argc, char **argv, char const *helptext, char const *progname, char const *version, char const *libname, char const *librelease)
This file contains the interface to class #SDH::cSDH, the end user class to access the SDH from a PC...
char sdh_canpeak_device[MAX_DEV_LENGTH]
A class to print colored debug messages.
char const * __copyright__
Interface of class #SDH::cCANSerial_PEAK, class to access CAN bus via PEAK card on cygwin/linux...
Interface of class #SDH::cCANSerial_ESD, class to access CAN bus via ESD card on cygwin/linux.
Implementation of a class to parse common SDH related command line options.
static char const * GetLibraryRelease(void)
This file contains interface and implementation of class #SDH::cDBG, a class for colorfull debug mess...
Low-level communication class to access a serial port.
Base class for exceptions in the SDHLibrary-CPP.
Interface of auxilliary utility functions for SDHLibrary-CPP.
virtual const char * what() const
#define USING_NAMESPACE_SDH
virtual int write(char const *ptr, int len=0)=0
Write data to a previously opened port.
This file contains settings to make the SDHLibrary compile on differen systems:
Low-level communication class to access a CAN port from company PEAK (http://www.peak-system.com)
int main(int argc, char **argv)
virtual void Open(void)=0
Open rs232 port port.
static char const * GetLibraryName(void)
class for command line option parsing holding option parsing results
USING_NAMESPACE_SDH NAMESPACE_SDH_START std::ostream * g_sdh_debug_log
virtual ssize_t Read(void *data, ssize_t size, long timeout_us, bool return_on_less_data)=0
Low-level communication class to access a CAN port from company ESD (http://www.esd.eu/)
cDBG dbg
A stream object to print colored debug messages.