Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-10

Sending files over a Nullmodem cable

7 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Karim

Hello

I play with the thought to write a socket program. This program should transfer large data files from my main computer to my notebook. For the connection, I want to use a nullmodem cable over the serial port. I will use the client/server model.

The first problem is, how to access the serialport in FreeBSD with FPC ? Are there any examples or units that I can study.

Greetings

Sonic Traveler

Karim -- http://www.fastmail.fm - Send your email first class
Marco van de Voort
to Karim
Show quoted text 7 lines
I play with the thought to write a socket program. This program should transfer large data files from my main computer to my notebook. For the connection, I want to use a nullmodem cable over the serial port. I will use the client/server model. The first problem is, how to access the serialport in FreeBSD with FPC ? Are there any examples or units that I can study.

No. Otoh, it is nothing more than configuring, and than reading/writing a device.

See e.g.

man sio (and specially note the "files" section) to see how serial ports are named.

However that is not socket based by default, you'd probably need to run SLIP on it.

Karim
to Marco van de Voort

Hello

I installed the SDL Bindings for FPC (FreeBSD). I compiled the bindings and copied
the all .ppu and object files in a SDL units directory. Now, I want to test sdl and the bindings with the examples the comes with the it. Like demo01.pp
When I try to compile it, I get this message:

x1-6-00-a0-24-7e-45-37# fpc demo01.pp
Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 Copyright (c) 1993-2003 by Florian Klaempfl
Target OS: FreeBSD/ELF for i386
Compiling demo01.pp
Assembling demo01
Linking demo01
/usr/bin/ld: cannot find -lSDL
demo01.pp(87) Error: Error while linking
Closing script ppas.sh

All my SDL libaries are installed in /usr/local/lib. I`ve also adapted the fpc.cfg file.
I`ve got similar error with the older FPC release and OpenGL, but not with the Linux FPC version.
I allready wrote to the sdl4pascal mailinglist, they told me to try it at the main fpc mailinglist.
Is this a known bug from the FreeBSD version ?

Greetings

Karim -- http://www.fastmail.fm - Consolidate POP email and Hotmail in one place
Marco van de Voort
to Karim

[ Charset ISO-8859-1 unsupported, converting... ]

Show quoted text 22 lines
Hello I installed the SDL Bindings for FPC (FreeBSD). I compiled the bindings and copied the all .ppu and object files in a SDL units directory. Now, I want to test sdl and the bindings with the examples the comes with the it. Like demo01.pp When I try to compile it, I get this message: x1-6-00-a0-24-7e-45-37# fpc demo01.pp Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 Copyright (c) 1993-2003 by Florian Klaempfl Target OS: FreeBSD/ELF for i386 Compiling demo01.pp Assembling demo01 Linking demo01 /usr/bin/ld: cannot find -lSDL demo01.pp(87) Error: Error while linking Closing script ppas.sh All my SDL libaries are installed in /usr/local/lib. I`ve also adapted the fpc.cfg file.

- If you have a {$linklib SDL} in your demo, make sure it is lowercase.
- Try to compile again, and if it fails, check if there is a SEARCH_DIR(/usr/local/lib) in the link.res file.

There is a problem with 1.0.10 OpenGL, but IIRC that was a missing "libdl"

A fix for that is at http:/www.stack.nl/~marcov/openglfreebsd.tar.gz

Karim
to Marco van de Voort

Hello

Marco, the link.res seems to be o.k . It looks like this:

SEARCH_DIR(/usr/lib/)
SEARCH_DIR(/usr/X11R6/lib/)
SEARCH_DIR(/usr/local/lib/)
SEARCH_DIR(/usr/local/lib/fpc/1.0.10/units/freebsd/rtl/) SEARCH_DIR(/usr/local/lib/fpc/1.0.10/units/freebsd/SDL4Freepascal-1.2.0.0/) etc.

I don`t know exactly what you mean with {$linklib SDL}... but I don`t have such an entry in the code.
The source that I`m trying to compile is this one (first demo from the sdl package):

{
SDL4FreePascal-1.2.0.0 - Simple DirectMedia Layer bindings for FreePascal
Copyright (C) 2000, 2001 Daniel F Moisset

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Daniel F Moisset

}

Program Demo01 ;

{
SDL4FreePascal Demo 01
======================

Just set the video mode.
}

{ SDL: Initialization and cleanup routines for SDL SDL_Video: The Video services
SDL_Types: Some Types and constants usually needed } Uses SDL, SDL_Video, crt;

Const
{ These are the screen parameters (window or videomode). When using a depth non supported by hardware, SDL automatically converts
to the requested depth, but it's slower than direct access. }

   width = 320 ;
   height = 240 ;
   colordepth = 16 ;

Var

   screen: PSDL_Surface ;
   { A PSDL_Surface is used to store bitmap video surfaces, for example
   the
     visible screen, non-visible areas of video memory, and memory areas
     used
     for storing pixmaps.
     This variable will be used to store the visible screen.
   }

Begin
{ SDL_Init must be called before doing anything with SDL. The parameter is a bitwise or of SDL_INIT_xxx constants, indicating which SDL subsystems will be used. }

   SDL_Init (SDL_INIT_VIDEO) ;
   { SDL_SetVideoMode creates a surface attached to the visible screen or
     window. Its last parameter indicates several flags for the surface.
     In this demo we're creating the surface in system memory (instead of
     video memory). This makes for faster pixel r/w access, but
     eventually
     is necessary to spend some time copying it to real video memory. A
     hardware surface must not be copied (it's already there), and may
     take
     advantage of hardware acceleration for blitting, but must be  locked
     and unlocked when accessing }
   screen := SDL_SetVideoMode (width, height, colordepth, SDL_SWSURFACE)
   ;
   { SDL_SetVideoMode returns nil if something fails }
   if screen = nil then
   Begin
       Writeln ('Couldn''t initialize video mode at ', width, 'x',
                height, 'x', colordepth, 'bpp') ;
       Halt(1)
   End ;
   Delay(5000) ; { Wait 5 seconds }
   { Allocated surfaces must be freed using SDL_FreeSurface }
   SDL_FreeSurface (screen) ;
   { SDL_Quit closes SDL  }
   SDL_Quit ;
   { The window/videomode closes just here (it's not closed by
   FreeSurface) }
   WriteLn('Now we are not using SDL')
End.

Now, the whole thing is bewildering, because I get a second error message which is diffrent from the old one.
The message looks like this:

-bash-2.05b$ fpc demo01.pp
Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 Copyright (c) 1993-2003 by Florian Klaempfl
Target OS: FreeBSD/ELF for i386
Compiling demo01.pp
Assembling demo01
Linking demo01
Compilation aborted demo01.pp:87
Runtime error 5 at 0x080BE16F
0x080BE16F
0x0809F874
0x0809F9C5
0x0804B325
0x0808904E
0x080884DA
0x08107AC9
0x080480E9

Can somebody explain to me, how I can get two diffrent error outputs with the same source code ?

Greetings

Karim -- http://www.fastmail.fm - mmm... Fastmail...
Marco van de Voort
to Karim
Show quoted text 25 lines
Now, the whole thing is bewildering, because I get a second error message which is diffrent from the old one. The message looks like this: -bash-2.05b$ fpc demo01.pp Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 Copyright (c) 1993-2003 by Florian Klaempfl Target OS: FreeBSD/ELF for i386 Compiling demo01.pp Assembling demo01 Linking demo01 Compilation aborted demo01.pp:87 Runtime error 5 at 0x080BE16F 0x080BE16F 0x0809F874 0x0809F9C5 0x0804B325 0x0808904E 0x080884DA 0x08107AC9 0x080480E9 Can somebody explain to me, how I can get two diffrent error outputs with

I don't have time atm to delve deeper in this, but the runtime error 5 seems some locking/sharing/permission violation, and unrelated to the problem at hand.

Marco van de Voort
to Karim: Hello Marco, the link.res seems to be o.k . It looks like this: SEARCH_DIR(/usr/lib/)…
Show quoted text 8 lines
Marco, the link.res seems to be o.k . It looks like this: SEARCH_DIR(/usr/lib/) SEARCH_DIR(/usr/X11R6/lib/) SEARCH_DIR(/usr/local/lib/) SEARCH_DIR(/usr/local/lib/fpc/1.0.10/units/freebsd/rtl/) SEARCH_DIR(/usr/local/lib/fpc/1.0.10/units/freebsd/SDL4Freepascal-1.2.0.0/) etc.

Hmm, I ssh'ed to some FreeBSD box with SDL installed, and it seems that FreeBSD names the libraries SDL-x.y

Simply do a

cd /usr/local/lib
ln -s libSDL-x.y.so libSDL.so

Maybe you need to do that for the other libSDL-*.so files too. (x.y=1.1 on my system)