Recent

Author Topic: serial unit free pascal  (Read 1212 times)

jb007

  • Full Member
  • ***
  • Posts: 145
serial unit free pascal
« on: April 23, 2023, 09:48:54 am »
Hi,

 recently started to get Rx/Tx functioning over GPIO on a PI-zero ( not a PI-w )
using free pascal, text editor based ( NOT Lazarus IDE ! ).

Try to find an overview of the functions/procedures of the serial unit.
Found only some example code on different sites.

Even wiki ( https://wiki.freepascal.org/Hardware_Access) shows:

'However there does not seem to be any documentation other than the Serial.pp source file and some discussions.'

Asking is free: someone has some more info of the contains of serial unit?

Kind regards. Marcel

to DIY or not to DIY

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: serial unit free pascal
« Reply #1 on: April 23, 2023, 10:14:02 am »
I did the last maintenance on that. Refer to the source unit.

There's a couple of minor issues in it:

* On unix, the device isn't locked (it is on Windows).

* Some settings aren't fully preserved/restored.

* It's intentionally a very thin wrapper around the host API. However on Linux there's a gotcha if using an ioctl to ask how much input is buffered: the result is truncated at 4K.

Refer to https://github.com/MarkMLl/serialcomms for stuff relating to the above.

However I have no immediate plan to work on that since I can't test a couple of the targets (Windows and SunOS hence probably the rest of the BSDs).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jb007

  • Full Member
  • ***
  • Posts: 145
Re: serial unit free pascal
« Reply #2 on: April 23, 2023, 10:34:32 am »
Tnx,
 
 gonna read/study the code
'Refer to https://github.com/MarkMLl/serialcomms for stuff relating to the above'.

Can take a while before I'll post again. Lot's going on refering to
Tx/Rx on the pi-GPIO e.g.: the config.txt, the cmdline.txt and 'tty' instead of 'com' etc etc...
Have put a scope on the GPIO TX, first see, If I can get a signal.

Tnx again.

To be continued. Marcel.

to DIY or not to DIY

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: serial unit free pascal
« Reply #3 on: April 23, 2023, 10:47:40 am »
It's very much intended as low-level code. When I did the maintenance I needed something I could put in a thread which timestamped each received byte ** , so while it could be wrapped in a component for Lazarus that's not what it was initially intended for.

If you have problems and I don't respond promptly here I suggest PMing me. I've got rather a lot of other things going on and aren't logged in as much as I used to be.

Apropos GPIO, and looking at the general case rather than just an RPi: there's multiple ways of accessing bits which include both the old /sys/class as well as a newer one via (something like) /dev/gpio. However when I looked at this a couple of years ago it was immature... see https://forum.lazarus.freepascal.org/index.php/topic,56063.msg417205.html#msg417205

** Edited to add: and signal change. I think that one of the things I added to older code was either the CD or RING signal, which I needed to track in the context of what I was doing.

MarkMLl
« Last Edit: April 23, 2023, 11:16:42 am by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jb007

  • Full Member
  • ***
  • Posts: 145
Re: serial unit free pascal
« Reply #4 on: April 25, 2023, 01:15:42 pm »
For the moment, I'm done...

I'll give it a break and soon I'll give it a fresh restart!

Briefly what I've done:

- pi Zero ( without WIFI/bluetooth )
- Raspbian GNU/LINUX 11 (bullseye) ( no desktop )
- free pascal 3.2.0 ( text based )

- raspi-config: disable SHH/serial
- config.txt     ( various adjustments )
- cmdline.txt  ( various adjustments )

- used code: https://wiki.lazarus.freepascal.org/Serial_unit

Have done it in many variations, combinations and followed multiple 'manuals'
but only got 'Status: -1' and 'Error: unable to send'.
( of course no signal Tx-signal on my oscilloscope.

I also did lots of variations, regarding in ComPortName:=
Tried it also with lost of tty- and ttyAMA variations
( tty0, tty0:, tty1, tty1:. tttAMA0, etc...)    )
including the corresponding setting in the config.txt and cmdline.txt

I'll give the it a break for a week...

Continuing of the rest of sw-project, lots to do!
( The rx/tx between some Arduino2560's is working fine,
  controlling 6-DOF robot arm, DIY:
  https://www.youtube.com/watch?v=E2g6hWzkJIA&list=PLcCKmeWXkrzQ_kWBD6VObuYYiVe-x1Ymo )

Kind regards. Marcel









to DIY or not to DIY

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: serial unit free pascal
« Reply #5 on: April 25, 2023, 02:06:40 pm »
You're running Linux but using Windows-style device names.

See the Echo and Term examples at the link I gave you a few days ago, https://github.com/MarkMLl/serialcomms

I didn't write that Wiki page, haven't checked it, don't have time to edit it, and it's not a resource I pointed you at.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jb007

  • Full Member
  • ***
  • Posts: 145
Re: serial unit free pascal
« Reply #6 on: April 25, 2023, 02:15:43 pm »
Ah, look!

I made a start few days ago analyzing https://github.com/MarkMLl/serialcomms
but forgot to continue...

Kind regards.

to DIY or not to DIY

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: serial unit free pascal
« Reply #7 on: April 25, 2023, 02:52:13 pm »
There's quite a lot of stuff conditioning the console (i.e. "keyboard and screen") side in the terminal example which you don't need to worry about. Some of the other units are there to walk through the /sys tree in order to try to work out which device (i.e. /dev/ttyACMx, /dev/ttyUSBx etc.) it to be used if you know the properties of the device you're talking to (see my MS2115B example etc.).

The code DOES work, and I use it heavily.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jb007

  • Full Member
  • ***
  • Posts: 145
Re: serial unit free pascal
« Reply #8 on: August 02, 2023, 08:36:33 pm »
Tnx again!

Explored and tried, but didn't manage to get Tx signal out of the pi's GPIO.

Took another aproach. First try to get Tx-signal 'outside' of FP on my pi, via command-line.

- /boot/config.txt enable_uart=1.
- echo "cobaltBlue" > /dev/ttyAMA0

( @9600baud )

Now, I know that it 'can' work. See picture.

With this I'll continue and explore your code, Mark!








to DIY or not to DIY

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: serial unit free pascal
« Reply #9 on: August 02, 2023, 08:40:34 pm »
Took another aproach. First try to get Tx-signal 'outside' of FP on my pi, via command-line.

- /boot/config.txt enable_uart=1.
- echo "cobaltBlue" > /dev/ttyAMA0

You'll be better off- /much/ better off- using GTKTerm for that sort of thing. It's very much designed for engineer's benchwork, with control/display of the various control lines etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018