Sign in Join

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

Mailing lists / fpc-pascal / 2013-07

synapser freezes on fopen(FDevice, 0_RDWR or 0_SYNC) on raspberry Pi

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Dennis Poon

I downloaded http://www.turbocontrol.com/easyfpgui.htm which as a zip of example of using synapse on ARM platform.
It worked on raspberry Pi (raspbian os) but it uses a specialized trimmed down version of Free Pascal library.
I need to work with the traditional free pascal library since my other part of programs rely on them.

However, when I extract the relevant code from that example and use the normal fpc compiler (2.6.0) instead of the pparm (2.6.2) and special fp lib inside that zip, my program freezes on synapser.pas TBlockSerial.Connect
at the line of fopen(FDevice, 0_RDWR or 0_SYNC).

I really don't understand what caused this? a different version of fpc compiler or a different fp lib or because their example is GUI app and mine is just a console mode app?

Any advice will be appreciated.

Thanks.

Dennis

Marco van de Voort
to Dennis Poon

In our previous episode, Dennis Poon said:

However, when I extract the relevant code from that example and use the normal fpc compiler (2.6.0) instead of the pparm (2.6.2)

The most recent version of the normal compiler is also 2.6.2

Ewald
to Dennis Poon: I downloaded http://www.turbocontrol.com/easyfpgui.htm which as a zip of example of…
Dennis Poon wrote
However, when I extract the relevant code from that example and use the normal fpc compiler (2.6.0) instead of the pparm (2.6.2) and special fp lib inside that zip, my program freezes on synapser.pas TBlockSerial.Connect at the line of fopen(FDevice, 0_RDWR or 0_SYNC).

Well, I recently had a similar issue, on Mac OS X and an USB to Serial converter (which had an FTDI chipset) -- maybe this issue is similar. The fix was really quite easy, but it took me a while to find out.

Assume your fpOpen() call returns a handle called `Handle`. Now add the following lines after your open call:

===Code===
Var Attr: TTermios;
tcgetattr(Handle, @Attr);
Attr.c_cflag:= Attr.c_cflag or CREAD or CLOCAL;		// --> This is the line that fixed the issue
//Do fix your other attributes here aswell, like ispeed, ospeed, etc...
tcsetattr(Handle, TCSADRAIN, @Attr);	// Take a look at the documentation of this call to see what constant (TCSADRAIN) you want to use.
===EOC===

Hope it helps!

Ewald
Dennis Poon
to Ewald

Ewald,

It does not fix it :-(
The weird thing is, now even if I run the trimmed down version compiled with 2.6.2, it also freezes.
But running
sudo minicom -b 9600 -o -D /dev/ttyAMA0
has no tried sudo -i
then startx
to run X window as root then execute the program, still freezes on connect to /dev/ttyAMA0

It is so weird :-(

Dennis

Ewald wrote 44 lines
On 08 Jul 2013, at 12:09, Dennis Poon wrote: > > However, when I extract the relevant code from that example and use > the normal fpc compiler (2.6.0) instead of the pparm (2.6.2) and > special fp lib inside that zip, my program freezes on synapser.pas > TBlockSerial.Connect > at the line of fopen(FDevice, 0_RDWR or 0_SYNC). Well, I recently had a similar issue, on Mac OS X and an USB to Serial converter (which had an FTDI chipset) -- maybe this issue is similar. The fix was really quite easy, but it took me a while to find out. Assume your fpOpen() call returns a handle called `Handle`. Now add the following lines after your open call: ===Code=== Var Attr: TTermios; tcgetattr(Handle, @Attr); Attr.c_cflag:= Attr.c_cflag or CREAD or CLOCAL; // --> This is the line that fixed the issue //Do fix your other attributes here aswell, like ispeed, ospeed, etc... tcsetattr(Handle, TCSADRAIN, @Attr); // Take a look at the documentation of this call to see what constant (TCSADRAIN) you want to use. ===EOC=== Hope it helps! -- Ewald _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal No virus found in this message. Checked by AVG - www.avg.com <http://www.avg.com> Version: 2013.0.3345 / Virus Database: 3204/6473 - Release Date: 07/08/13
Dennis Poon
to Dennis Poon

Although not 100% sure, I kinda fixed the problem. I remove a lot *.o *.ppu from the example and recompile again, both fpc 2.6 and ppcarm 2.6.2 can produce programs that work.

I don't understand why and I am happy for now.
thanks for advice.

Dennis

Dennis Poon wrote 74 lines
Ewald, It does not fix it :-( The weird thing is, now even if I run the trimmed down version compiled with 2.6.2, it also freezes. But running sudo minicom -b 9600 -o -D /dev/ttyAMA0 has no problem at all. I tried sudo -i then startx to run X window as root then execute the program, still freezes on connect to /dev/ttyAMA0 It is so weird :-( Dennis Ewald wrote: > On 08 Jul 2013, at 12:09, Dennis Poon wrote: >> >> However, when I extract the relevant code from that example and use >> the normal fpc compiler (2.6.0) instead of the pparm (2.6.2) and >> special fp lib inside that zip, my program freezes on synapser.pas >> TBlockSerial.Connect >> at the line of fopen(FDevice, 0_RDWR or 0_SYNC). > > Well, I recently had a similar issue, on Mac OS X and an USB to > Serial converter (which had an FTDI chipset) -- maybe this issue is > similar. The fix was really quite easy, but it took me a while to > find out. > > Assume your fpOpen() call returns a handle called `Handle`. Now add > the following lines after your open call: > > ===Code=== > Var Attr: TTermios; > > tcgetattr(Handle, @Attr); > > Attr.c_cflag:= Attr.c_cflag or CREAD or CLOCAL; // --> This is the > line that fixed the issue > //Do fix your other attributes here aswell, like ispeed, ospeed, etc... > > tcsetattr(Handle, TCSADRAIN, @Attr); // Take a look at the > documentation of this call to see what constant (TCSADRAIN) you want > to use. > ===EOC=== > > Hope it helps! > > -- > Ewald > > > _______________________________________________ > fpc-pascal maillist > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > No virus found in this message. > Checked by AVG - www.avg.com <http://www.avg.com> > Version: 2013.0.3345 / Virus Database: 3204/6473 - Release Date: 07/08/13 > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal No virus found in this message. Checked by AVG - www.avg.com <http://www.avg.com> Version: 2013.0.3345 / Virus Database: 3204/6473 - Release Date: 07/08/13