Recent

Author Topic: Use ttyS0, exsample code? For Linux  (Read 341 times)

coradi

  • Full Member
  • ***
  • Posts: 160
Use ttyS0, exsample code? For Linux
« on: September 20, 2024, 08:01:58 pm »
Hallo,
is tehre any exsample code for using Serial ports with USb Converter (ttyS0)?
A simple open Port, and read port, or send and read back from same RX/TX?
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

MarkMLl

  • Hero Member
  • *****
  • Posts: 7884
Re: Use ttyS0, exsample code? For Linux
« Reply #1 on: September 20, 2024, 09:18:23 pm »
https://github.com/MarkMLl/serialcomms plus several others in the same repo.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

coradi

  • Full Member
  • ***
  • Posts: 160
Re: Use ttyS0, exsample code? For Linux
« Reply #2 on: September 20, 2024, 10:47:30 pm »
Great, I will try
Amstrad Schneider CPC 6128
AVR8/ARM(STM32)

MarkMLl

  • Hero Member
  • *****
  • Posts: 7884
Re: Use ttyS0, exsample code? For Linux
« Reply #3 on: September 21, 2024, 09:20:46 am »
That's obviously based on the standard serial.pp, which hasn't had any attention for many years /but/ was tested on Linux, Windows (2Kish?) and SunOS/Solaris (which should be fairly similar to MacOS or whatever it's called).

It extended work that somebody else had done, but I was specifically focusing on low-level access and the calls will typically be in their own thread. At the time I was working on a serial comms analyzer (to capture the protocol between two commercial comms analyzers) and I very much wanted each captured byte to have a timestamp and a snapshot of the control line states.

On Windows it gets sole-access to the port, on unix it doesn't (which is something I'd be inclined to change). Also it doesn't have a SerAvailable(), but in Linux that has a gotcha: the result is truncated at 4K. More details in that repo, which also has stuff to detect various USB devices (which in practice are often built into e.g. a multimeter, Arduino etc.).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018