How can I set a non standard baudrate with PB ?

Mac OSX specific forum
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

How can I set a non standard baudrate with PB ?

Post by infratec »

Hi Mac OS X gurus,

yesterday I had the chance to test one of my programs on Mac OS X.
In general it works, but...
I have to open the serial port with a non standard baudraute.
The Linux method is not working :(

Code: Select all

LinuxSerialInfo.serial_struct

ioctl_(Handle , #TIOCGSERIAL, @LinuxSerialInfo)

LinuxSerialInfo\flags | #ASYNC_SPD_CUST
LinuxSerialInfo\custom_divisor = LinuxSerialInfo\baud_base / Baud

ioctl_(Handle, #TIOCSSERIAL, @LinuxSerialInfo)
Any ideas :?:

I only found examples with IOSSIOSPEED in 'C', but no idea how I can use this
in combination with PB.

Hope somebody can help me.

Bernd
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: How can I set a non standard baudrate with PB ?

Post by wilbert »

I think it should be something like this

Code: Select all

#IOSSIOSPEED = $80045402

fileDescriptor = OpenSerialPort(0, "/dev/tty.Bluetooth-PDA-Sync", 300, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake, 1024, 1024)

speed.l = 14400
If ioctl_(fileDescriptor, #IOSSIOSPEED, @speed) = -1
  Debug "error setting speed"
EndIf
but I'm not sure.
I guess only someone from the PB dev team can tell you the proper way to get the fileDescriptor .
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: How can I set a non standard baudrate with PB ?

Post by infratec »

Hi Wilbert,

thanks for your reply. I hope that I can test this soon.
For the fd I use the following for Linux:

Code: Select all

If SerialPort = #PB_Any
  Handle = SerialPortID(Port)
Else
  Handle = Port
EndIf
I think it is the same on the Mac.

Bernd
Post Reply