I find this in Stackoverflow :


for linux there are a solution using ioctl, but is very different to MacOS:

I accomplished this using termios2 and ioctl() commands.

struct termios2 options;
ioctl(fd, TCGETS2, &options);
options.c_cflag &= ~CBAUD;    //Remove current BAUD rate
options.c_cflag |= BOTHER;    //Allow custom BAUD rate using int input
options.c_ispeed = 307200;    //Set the input BAUD rate
options.c_ospeed = 307200;    //Set the output BAUD rate
ioctl(fd, TCSETS2, &options);

After that, you should be able to query the port settings and see your custom BAUD rate, as well as the other settings (possible with stty commands).

so ioctl is the same, but the "low level functions" who are called are different, for BSD appears to be similar to MacOS, but because of the differences  I think is better if each plugin file is different.

On 20 Mar 2018, at 12:43, Eliot Miranda <eliot.miranda@gmail.com> wrote:

Hi Javier,

On Sun, Mar 18, 2018 at 7:50 AM, Javier Diaz-Reinoso <javier_diaz_r@mac.com> wrote:
I am not sure if the code of MacOS for "support arbitrary serial speeds" is valid in Linux, the code in pyserial (https://github.com/pyserial/pyserial/blob/master/serial/serialposix.py) is:

elif plat[:6] == 'darwin': # OS X
import array
IOSSIOSPEED = 0x80045402 # _IOW('T', 2, speed_t)
class PlatformSpecific(PlatformSpecificBase):
osx_version = os.uname()[2].split('.')
# Tiger or above can support arbitrary serial speeds
if int(osx_version[0]) >= 8:
def _set_special_baudrate(self, baudrate):
# use IOKit-specific call to set up high speeds
buf = array.array('i', [baudrate])
fcntl.ioctl(self.fd, IOSSIOSPEED, buf, 1)

can the equivalent in C work in linux or the other unix?.

It should be able to, right?  It's just an ioctl.  Can you try and see and commit the results to opensmalltalk/vm, e.g. as a pull request?

At the moment I only use SqPronterface in mac (MacBook Pro or iBook G4) connected to an Arduino Mega controlling a Prusa  Mendel printer.

best, Eliot