Go to the documentation of this file.
19 #if defined(__APPLE__)
28 #include <sys/ioctl.h>
31 #include <mach/clock.h>
32 #include <mach/mach.h>
37 #define LATENCY_TIMER 16 // msec (USB latency timer)
50 baudrate_(DEFAULT_BAUDRATE_),
51 packet_start_time_(0.0),
114 ioctl(
socket_fd_, FIONREAD, &bytes_available);
115 return bytes_available;
153 #ifdef __MACH__ // OS X does not have clock_gettime, so here uses clock_get_time
156 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
157 clock_get_time(cclock, &mts);
158 mach_port_deallocate(mach_task_self(), cclock);
159 tv.tv_sec = mts.tv_sec;
160 tv.tv_nsec = mts.tv_nsec;
162 clock_gettime(CLOCK_REALTIME, &tv);
164 return ((
double)tv.tv_sec * 1000.0 + (
double)tv.tv_nsec * 0.001 * 0.001);
180 struct termios newtio;
185 printf(
"[PortHandlerMac::SetupPort] Error opening serial port!\n");
189 bzero(&newtio,
sizeof(newtio));
191 newtio.c_cflag = CS8 | CLOCAL | CREAD;
192 newtio.c_iflag = IGNPAR;
195 newtio.c_cc[VTIME] = 0;
196 newtio.c_cc[VMIN] = 0;
197 cfsetispeed(&newtio, cflag_baud);
198 cfsetospeed(&newtio, cflag_baud);
210 printf(
"[PortHandlerMac::SetCustomBaudrate] Not supported on Mac!\n");
void clearPort()
The function that clears the port @description The function clears the port.
int getCFlagBaud(const int baudrate)
bool setBaudRate(const int baudrate)
The function that sets baudrate into the port handler @description The function sets baudrate into th...
bool is_using_
shows whether the port is in use
void setPortName(const char *port_name)
The function that sets port name into the port handler @description The function sets port name into ...
bool openPort()
The function that opens the port @description The function calls PortHandlerMac::setBaudRate() to ope...
int readPort(uint8_t *packet, int length)
The function that reads bytes from the port buffer @description The function gets bytes from the port...
void setPacketTimeout(uint16_t packet_length)
The function that sets and starts stopwatch for watching packet timeout @description The function set...
int writePort(uint8_t *packet, int length)
The function that writes bytes on the port buffer @description The function writes bytes on the port ...
void closePort()
The function that closes the port @description The function closes the port.
double packet_start_time_
int getBaudRate()
The function that returns current baudrate set into the port handler @description The function return...
int getBytesAvailable()
The function that checks how much bytes are able to be read from the port buffer @description The fun...
char * getPortName()
The function that returns port name set into the port handler @description The function returns curre...
bool isPacketTimeout()
The function that checks whether packet timeout is occurred @description The function checks whether ...
PortHandlerMac(const char *port_name)
The function that initializes instance of PortHandler and gets port_name @description The function in...
bool setupPort(const int cflag_baud)
void setPortName(const char *port_name)
The function that sets port name into the port handler @description The function sets port name into ...
bool setCustomBaudrate(int speed)
double getTimeSinceStart()
dynamixel_sdk
Author(s): Gilbert
, Zerom , Darby Lim , Leon
autogenerated on Wed Mar 2 2022 00:13:50