AmigaOS4 Serial Device Examples

Find quick help here to get you started with Hollywood
Post Reply
seventhwonder
Posts: 7
Joined: Wed Jul 18, 2018 3:11 pm

AmigaOS4 Serial Device Examples

Post by seventhwonder »

Dear all

Is it possible to share code snippets for serial device support on AmigaOS4.

Especially writing to serial device and reading the output from serial.device ?

Thank youç
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: AmigaOS4 Serial Device Examples

Post by plouf »

There are some simol examples here
viewtopic.php?p=16047#p16047

Should work in all oses.
However be aware that current version of hollywood uses hardcoded the serial.device. in aos4 more or less you need to use another device (since serial.device is classic amiga internal device)

This is implemented in NEXT version of holywood
Christos
SMF
Posts: 3
Joined: Thu Mar 12, 2015 11:14 pm

Re: AmigaOS4 Serial Device Examples

Post by SMF »

The sources for SerialThing helped me when doing my first program in hollywood.
SerialTing can be downloaded from http://os4depot.net/?function=showfile& ... lthing.lha

The hollywood manual was not so great at describing how to set the baudrate so i struggled quite a lot with that until i looked at the sources for serialthing.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: AmigaOS4 Serial Device Examples

Post by airsoftsoftwair »

SMF wrote: Tue Dec 29, 2020 9:13 am The hollywood manual was not so great at describing how to set the baudrate so i struggled quite a lot with that until i looked at the sources for serialthing.
Really? What was so unclear in the doc? Let me know and I'll try to improve it :)
SMF
Posts: 3
Joined: Thu Mar 12, 2015 11:14 pm

Re: AmigaOS4 Serial Device Examples

Post by SMF »

airsoftsoftwair wrote: Wed Dec 30, 2020 11:03 pm
SMF wrote: Tue Dec 29, 2020 9:13 am The hollywood manual was not so great at describing how to set the baudrate so i struggled quite a lot with that until i looked at the sources for serialthing.
Really? What was so unclear in the doc? Let me know and I'll try to improve it :)
Sorry :P

I'm not sure if it was an user error or a bug ? :O
I'm a total n00b and have only completed one projekt with hollywood so i'm still learning how to read the manual.

But when setting up the serial connection there are some constants for baud rate etc.
I did struggle with the connection alot and tested everything i could think of.
Hollywod seemed to accept the baudrate i used (#BAUD_38400) but the recieving partner ended up with just garbage.
This made me think that the baudrate was not correctly set.

In the end i found source code for another project that helped me set the baud rate correctly.

So i ended up with this code to set the baud rate to 384000 etc.

Code: Select all


/* Create table for serial communication */
p		= {}		; initialize prefs table
p.unit 	= 1			; Serial.device unit 1
p.bauds = 5			; 38400
p.bits	= 3			; 8
p.parity= 0			; N
p.stop	= 0			; 1
p.flow	= 0			; None
  Local t={
           Baudrate=p.bauds,							; Serial settings table
           DataBits=p.bits,
           StopBits=p.stop,
           Parity=p.parity,
           FlowControl=p.flow
          }
  sid = OpenSerialPort(1,p.unit,t)					; Open serial port

There was no way that i could understand from the manual that 5 = #BAUD_38400
I have not kept an example of how i did try to set up the connection from the beginning but i was using the #BAUD constant and hollywood seemed to gladly accept it but it did not change the baudrate.
This was on OS4 btw.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: AmigaOS4 Serial Device Examples

Post by airsoftsoftwair »

SMF wrote: Sun Jan 10, 2021 8:34 am There was no way that i could understand from the manual that 5 = #BAUD_38400
But you don't have to know that! Just use the constant instead of its value, i.e.

Code: Select all

p.bauds = #BAUD_38400
That's what those constants are actually for ... to make the code more readable because nobody knows what's going on when you do

Code: Select all

p.bauds = 5
although it is technically the same as the first code.
Post Reply