Recent

Author Topic: Serial port component?  (Read 35805 times)

zkv

  • Newbie
  • Posts: 1
Serial port component?
« on: March 21, 2007, 08:35:18 pm »
Hi all!
is there a serial port component for Lazarus?
thanks in advance,
bye
zkv

RudieD

  • Full Member
  • ***
  • Posts: 234
RE: Serial port component?
« Reply #1 on: March 22, 2007, 05:08:10 pm »
Have a look at <http://wiki.lazarus.freepascal.org/Hardware_Access>
The FRED Trainer. (Training FRED with Lazarus/FPC)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
RE: Serial port component?
« Reply #2 on: March 22, 2007, 09:45:39 pm »
Please, don´t cross-post. I removed the other topic.

jezevec

  • Newbie
  • Posts: 2
Re: Serial port component?
« Reply #3 on: April 05, 2007, 07:19:46 pm »
Quote from: "zkv"
Hi all!
is there a serial port component for Lazarus?
thanks in advance,
bye
zkv


Yes, of course,
you can use a Synaser by Lukas Gebauer... (www.araat.cz/synapse or so...)
 :D

badger

lewjoubert

  • New Member
  • *
  • Posts: 23
    • http://www.contact51.com
Serial port component?
« Reply #4 on: July 25, 2007, 01:30:30 pm »
Hi,

I struggled for ages trying to find a way to easily use the serial port. I could not get Synaser to work, ever - all in all a very frustrating few months.
Then I discovered that all along, the tools I needed where right there under the Lazarus/FPC bonnet!!

To get the serial (Comm) or in Linux ttyS0 to work very easily, simply add to the 'Uses' clauses 'Serial' (without the quotes of course).

Remember: ttyS0 = CommPort #1;  ttyS1 = CommPort #2 and so on.

To set the port parameters:
In the FormCreate procedure ---
    MySerial := SerOpen('/dev/ttyS0');
    SerSetParams(MySerialHandle, 9600,8,EvenParity,1,[]);

To write data to the port:
   eg: Write the following two characters YU
   Declare a string variable - bffr
   bffr := 'YU';
   SerWrite(MySerialHandle, bffr,2);   //The 2 here is to send 2 characters

To read data from the port:
   Place a Timer on the form and set its interval to 200. This will cause the     port to be polled every 200mSec.
   SerRead(MySerialHandle,bffr,1);   // The 1 here is to read 1 character

    if bffr = 'S' then
    begin
         "do stuff here depending on character received etc...."
    end

Also use SerFlush(MySerialHandle); to flush the buffer if necessary.

Then of course, by default the serial port on a Linux box is inactive. So you need to activate it before you can get any comms going. This is a fairly simple matter of setting permissions.

As super user (or sudo, administrator or whatever) you can do:

1) chmod 666 ttyS0 from within the /dev directory.
However this permission setting will last only as long as your session. Rebooting will revert back to inactive ttyS0.

2) Permanently enabling the serial port.
In Fedora Core 5 for example:
Select the file /etc/udev/rules.d/50-udev.rules
Change the existing line that starts with KERNEL == "tty" to the following:
KERNEL=="tty[A-Z]*",NAME="%k",GROUP="MYGROUP", MODE="666";

I noticed on a box running SuSE 9.1 that doing a chmod 666 ttys0 set the permissions permanently. Also SuSE does not use the same diectory as depicted above for Fedora 5.
You will need to find out how to permanently enable the serial port for the type of distro you are running.

Hope this info of of use.

Paulei

  • Newbie
  • Posts: 1
Serial port component?
« Reply #5 on: October 11, 2007, 08:46:13 am »
Hi.
And serial interrupts, like 'data received' !?
I don't want to test all times if there's any comunication!

 :roll:

Tx

Tauri

  • Newbie
  • Posts: 1
Serial port component?
« Reply #6 on: March 30, 2008, 10:39:57 pm »
Small corection in write data to the port:

SerWrite(MySerialHandle, bffr[1],2); //The 2 here is to send 2 characters

By Tadej

hy

  • Full Member
  • ***
  • Posts: 213
Serial port component?
« Reply #7 on: April 24, 2008, 04:53:30 pm »
Hi does this work with USB-Ports as well?
_____
***hy
OS: debian sid(64bit)  [fpc 3.0.4] Lazarus SVN

cyber_python

  • Jr. Member
  • **
  • Posts: 79
Serial port component?
« Reply #8 on: April 24, 2008, 05:11:21 pm »

hy

  • Full Member
  • ***
  • Posts: 213
TNX 4 the link
« Reply #9 on: April 24, 2008, 10:42:46 pm »
TNX 4 the link, i've bookmarked it. andit sure will help me to transform my Gps-Application from Delphi 2 Lazarus.
_____
***hy
OS: debian sid(64bit)  [fpc 3.0.4] Lazarus SVN

pmalheiros

  • Newbie
  • Posts: 3
RE: TNX 4 the link
« Reply #10 on: April 24, 2008, 11:14:06 pm »
There's a serial port component in http://wiki.lazarus.freepascal.org/5dpo
It's a visual implementation of synaser and it works in Linux and Windows.

Bye
pmalheiros

windy

  • Full Member
  • ***
  • Posts: 186
RE: TNX 4 the link
« Reply #11 on: June 07, 2008, 01:28:38 am »
Hi
I am looking for a serial component/library or similar for use with a PowerPC mac
I tried the 5dpo/synaser, but the PowerPC platform has hardware differences by the looks that is causing problems with the compiling of the synaser.pas file
Does anyone know of a possible solution?
I do have a library file that is developed under c++ , using libc, and that works OK under linux and the Mac intel, but with the Mac powerpc, it locks up when the comport is tried to be opened....not sure if that is a driver install issue for the usb to serial adaptor (i.e might need a different driver for the powerpc (but it does show up ok when doing ls /de/tty.*), or its because of archeticural differences with the Power PC and a Intel PC?
Thanks!
(ps, sorry for replying to an old thread)

tech-pro

  • Full Member
  • ***
  • Posts: 173
    • Tech-Pro.net
RE: TNX 4 the link
« Reply #12 on: June 11, 2008, 12:32:14 am »
Don't know anything about Power PC but my program using synaser under Windows receives mostly gobbledygook when using a Prolific-based USB to serial adapter although it works fine talking to the same device at the same speed with a real serial port. So I'm interested in knowing if there is an alternative too, though in my case it needs to work on Windows and Linux.

Many USB to serial port adapters don't make a good emulation of a serial port but problems can often be solved by trying a different adapter with a different chipset.
Julian

windy

  • Full Member
  • ***
  • Posts: 186
RE: TNX 4 the link
« Reply #13 on: June 14, 2008, 06:20:31 am »
HI
yes, I agree that some usb to serial adaptors are better than others
your problem sounds like the baud rate by need to be set correctly?

My usb to serial works OK on my Intel Mac, but the same compiled/ported code on the PowerPC (and same driver loaded), it locks up when the port is tried to open
so thats why I wanted to try out synaser.pas   ,but that is not compiling on the powerpc....