35 #ifndef ROS_EMBEDDED_LINUX_HARDWARE_H_ 36 #define ROS_EMBEDDED_LINUX_HARDWARE_H_ 40 #ifdef BUILD_LIBROSSERIALEMBEDDEDLINUX 41 extern "C" int elCommInit(
char *portName,
int baud);
43 extern "C" elCommWrite(
int fd, uint8_t* data,
int length);
52 #include <mach/mach.h> 53 #include <mach/mach_time.h> 54 static mach_timebase_info_data_t sTimebaseInfo;
57 #define DEFAULT_PORT "/dev/ttyAM1" 70 const char *envPortName = getenv(
"ROSSERIAL_PORT");
71 if (envPortName == NULL)
94 std::cout <<
"Exiting" << std::endl;
97 std::cout <<
"EmbeddedHardware.h: opened serial port successfully\n";
107 std::cout <<
"Exiting" << std::endl;
110 std::cout <<
"EmbeddedHardware.h: opened comm port successfully\n";
121 void write(uint8_t* data,
int length)
129 clock_gettime(CLOCK_MONOTONIC, &start);
135 long seconds, nseconds;
137 clock_gettime(CLOCK_MONOTONIC, &end);
139 seconds = end.tv_sec - start.tv_sec;
140 nseconds = end.tv_nsec - start.tv_nsec;
142 return ((seconds) * 1000 + nseconds / 1000000.0) + 0.5;
148 start = mach_absolute_time();
149 mach_timebase_info(&sTimebaseInfo);
155 uint64_t elapsed = mach_absolute_time() - start;
156 return elapsed * sTimebaseInfo.numer / (sTimebaseInfo.denom * 1000000);
166 struct timespec start;
void init(const char *pName)
int elCommWrite(int fd, uint8_t *data, int len)
void write(uint8_t *data, int length)
EmbeddedLinuxHardware(const char *pn, long baud=57600)
int elCommInit(const char *portName, int baud)