Sorry my HROS1 has been sitting in dust for several years now. Probably not likely to be resurrected anytime soon.
But back then I know I had played with a few different processors, like Edison and RPI3 and I believe an ODroid.
If it were me now, probably the first place I would look at is the file fuild\LinuxArbotixPro.cpp,
Probalby in the function: bool LinuxArbotixPro::OpenPort()
It is trying to set the baud rate to 1mbs, which is a non-standard baudrate. It has been a long while since I looked at this, but the usages of tcsetattr may work differently depending on processor especially for non-standard settings. I know I ran into this before, but don't remember what the differences were.
If I look at my also old Raspberry Pi project that I have played around with different Linux boards where I had ports of the Hexapod code base and the like:.
Looking in that code base where I am trying to open up a serial port at some baud rate I do see I have a couple different ways:
Code:
int dxl_hal_open(int deviceIndex, float baudrate)
{
struct termios newtio;
struct serial_struct serinfo;
char dev_name[20] = "/dev/ttyDXL";
uint32_t int_baud = baudrate;
#ifdef DEBUG_WIRINGPI
wiringPiSetup () ;
pinMode (WPD_WRITE_PIN, OUTPUT) ;
pinMode (WPD_READ_PIN, OUTPUT) ;
pinMode (WPD_READ_DATA_PIN, OUTPUT) ;
pinMode (WPD_FLUSH_PIN, OUTPUT) ;
pinMode (WPD_CLEAR_PIN, OUTPUT) ;
#endif
// Build in support to explit device - /dev/ttyDXL
dxl_hal_close(); // Make sure any previous handle is closed
if((gSocket_fd = open(dev_name, O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0) {
// We did not find our explicit one, lets try the standard default USB2AX file name
sprintf(dev_name, "/dev/ttyACM%d", deviceIndex); // USB2AX is ttyACM
if((gSocket_fd = open(dev_name, O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0) {
fprintf(stderr, "device open error: %s\n", dev_name);
// Lets also try ttyUSBx to see if we have different board...
sprintf(dev_name, "/dev/ttyUSB%d", deviceIndex); // USB2AX is ttyACM
if((gSocket_fd = open(dev_name, O_RDWR|O_NOCTTY|O_NONBLOCK)) < 0) {
fprintf(stderr, "device open error: %s\n", dev_name);
goto DXL_HAL_OPEN_ERROR;
}
g_use_tcdrain = 1; // FTDI device use tc Drain.
}
} else {
// DXL found see if FTDI as to know if we should use drain.
char szProcFD[20];
char szPath[30];
int ich;
sprintf(szProcFD, "/proc/self/fd/%d", gSocket_fd);
ich = readlink(szProcFD, szPath, sizeof(szPath));
// Hack look for /dev/ttyUSB... actuall only look at USB
if ((ich > 0) && (szPath[8]=='U') && (szPath[9]=='S')&& (szPath[10]=='B'))
g_use_tcdrain = 1; // FTDI use drain...
else
g_use_tcdrain = 0; // Others ACM S2.. Don't appear to.
}
if(gSocket_fd == -1)
return 0;
gfByteTransTime = (float)((1000.0f / baudrate) * 12.0f);
memset(&newtio, 0, sizeof(newtio));
// First try to set the baud rate directly.
switch (int_baud) {
case 4000000:
newtio.c_cflag = B4000000|CS8|CLOCAL|CREAD;
break;
case 3500000:
newtio.c_cflag = B3500000|CS8|CLOCAL|CREAD;
break;
case 3000000:
newtio.c_cflag = B3000000|CS8|CLOCAL|CREAD;
break;
case 2500000:
newtio.c_cflag = B2500000|CS8|CLOCAL|CREAD;
break;
case 2000000:
newtio.c_cflag = B2000000|CS8|CLOCAL|CREAD;
break;
default:
newtio.c_cflag = B1000000|CS8|CLOCAL|CREAD;
break;
}
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = 0;
newtio.c_cc[VTIME] = 0; // time-out ? (TIME * 0.1?) 0 : disable
newtio.c_cc[VMIN] = 0; // MIN ? read ? return ?? ?? ?? ?? ??
tcflush(gSocket_fd, TCIFLUSH);
if (tcsetattr(gSocket_fd, TCSANOW, &newtio) < 0) {
printf("tcsetattr 1000000 failed try indirect %d\n\r", errno);
// Try doing it indirect by setting to 38400 and
// see if the USB driver supports setting non-standard
// Try back at 38400 and setting attribute...
newtio.c_cflag = B38400|CS8|CLOCAL|CREAD;
if (tcsetattr(gSocket_fd, TCSANOW, &newtio) < 0) {
printf("tcsetattr failed %d\n\r", errno);
goto DXL_HAL_OPEN_ERROR;
}
// Get the settings...
if (ioctl(gSocket_fd, TIOCGSERIAL, &serinfo) < 0) {
printf("TIOCGSERIAL failed %d\n\r", errno);
goto DXL_HAL_OPEN_ERROR;
}
serinfo.flags &= ~ASYNC_SPD_MASK;
serinfo.flags |= ASYNC_SPD_CUST;
serinfo.custom_divisor = serinfo.baud_base / baudrate;
if(ioctl(gSocket_fd, TIOCSSERIAL, &serinfo) < 0) {
printf("TIOCSSERIAL failed %d\n\r", errno);
goto DXL_HAL_OPEN_ERROR;
}
}
return 1;
DXL_HAL_OPEN_ERROR:
dxl_hal_close();
return 0;
}
Again this is in my "Raspberry_Pi" project up on github.
With this version my code first tries to directly set the Serial port to 1mbs and only if this fails does it try the indirect approach of 38400 and setting different speed... Maybe now you can simply go direct with the newer compilers.
Good luck
Bookmarks