Re: [Lazarus] How to list available serial ports on Linux?

2020-10-06 Thread Corpsman via lazarus
That is how do it:

Function GetSerialPortNames(): String;
Var
  sl: TStringlist;
Var
  Info: TSearchRec;
  hdl: THandle;
  b: Boolean;
Begin
  sl := TStringlist.create;
  If FindFirst('/dev/tty*', faSysFile, Info) = 0 Then Begin
    Repeat
  b := true;
  Try
    hdl := FileOpen('/dev/' + info.Name, fmOpenReadWrite);
    If hdl = -1 Then Begin
  b := false;
    End;
  Except
    b := false;
  End;
  If hdl >= 0 Then Begin
    FileClose(hdl);
  End;
  If b Then Begin
    sl.Add('/dev/' + info.Name);
  End;
    Until FindNext(info) <> 0;
  End;
  FindClose(Info);
  result := sl.CommaText;
  sl.free;
End;

On 10/6/20 11:35 PM, Bo Berglund via lazarus wrote:
> Is there a way to list the available (working) serial ports on a Linux
> platform like the RaspberryPi?
>
> I would like to offer a dropdown list of working serial ports to the
> user to select among, but I am dissuaded from it when I do the
> following:
>
> ls -la /dev/tty*
> It returns a very long list of serial devices and most of these are
> probably not even existing in real life.
>
> On an RPi I get
> /dev/tty
> /dev/ttyN (where N=0..63
> /dev/ttyAMA0 <== This is RPi Serial0 port on the pin header.
> /dev/ttyprintk
> and:
> /dev/ttyUSB0../dev/ttyUSB3 depending on what is plugged into USB
>
> All in all about 70 devices, but not sure which are actually available
> for use.
>
> Is this an impossible task or can one check for "live" serial ports
> only? If so how?
>
> On Windows I have ported a convoluted function from Delphi, which uses
> Registry reads to give me the list.
>
>

--

Auf meiner Homepage www.Corpsman.de ist immer was los, ständig wird sie 
aktualisiert und erweitert. Da ist für jeden was dabei.

--

Schütze deine Privatsphäre, nutze E-mail Verschlüsselung.
Wie das geht steht z.B. hier :
https://support.mozilla.org/en-US/kb/digitally-signing-and-encrypting-messages#w_installing-gpg-and-enigmail

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Win 7 issue / Re: -dWINDOWS_LIGATURE [[Re: Font ligatures support]]

2020-10-06 Thread Maxim Ganetsky via lazarus

06.10.2020 16:23, Martin Frb via lazarus пишет:

On 06/10/2020 15:09, Maxim Ganetsky via lazarus wrote:



Can you try to catch it in the debugger, and see what params are given
to NewTextOut
in
#2  0x00ab95f6 in DRAWHILIGHTMARKUPTOKEN (ATOKENINFO=...,
parentfp=0x13abf6e8)
 at lazsyntextarea.pp:1741

  fTextDrawer.NewTextOut(TxtLeft, rcToken.Top, TxtFlags, tok,
ATokenInfo.Tk.TokenStart, ATokenInfo.Tk.TokenLength, FEtoBuf);
Can you add some debugln in a format convenient to you? This will
simplify things, I think.

This is in the paint handler, and it is called for each token. So 
potentially very slow with debugln.


But since it is in startup, hopefully you wont have to many.

Apply this patch please



With this patch applied Lazarus seems to crash on debugln in 
lazsyntextarea.pp. Just in case, I tried to remove this particular 
debugln, then it printed 'BEFORE' and nothing more.


i:\FPC\lazarus>lazarus --debug-output=.\dbgoutput.txt
Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] 
PrimaryConfigPath="C:\Users\Maxim

\AppData\Local\lazarus"
Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] 
SecondaryConfigPath="i:\FPC\lazar

us"
Hint: (lazarus) [TMainIDE.LoadGlobalOptions]
Hint: (lazarus) LastCalled="I:\FPC\lazarus\lazarus.old.working.exe"
Hint: (lazarus) CurPrgName="i:\FPC\lazarus\lazarus.exe"
Hint: (lazarus) 
AltPrgName="C:\Users\Maxim\AppData\Local\lazarus\bin\lazarus.exe

"
Hint: (lazarus) [TBuildManager.SetBuildTarget] Old=i386-win32-win32 
New=i386-win

32-win32 Changed: OS/CPU=True LCL=False
TApplication.HandleException: EAccessViolation
Access violation
  Stack trace:
  $00C12B2D  DRAWHILIGHTMARKUPTOKEN,  line 1740 of lazsyntextarea.pp
  $00C11C76  PAINTLINES,  line 1799 of lazsyntextarea.pp
  $00C11847  PAINTTEXTLINES,  line 1871 of lazsyntextarea.pp
  $00C113D8  DOPAINT,  line 1489 of lazsyntextarea.pp
  $00C07EA0  PAINT,  line 1308 of syneditmiscclasses.pp
  $00C0FDD2  DOPAINT,  line 1134 of lazsyntextarea.pp
  $00C07EA0  PAINT,  line 1308 of syneditmiscclasses.pp
  $00D9A022  DOPAINT,  line 1353 of sourcesyneditor.pas
  $00C07EA0  PAINT,  line 1308 of syneditmiscclasses.pp
  $0079ECCB  PAINT,  line 4221 of synedit.pp
  $005B3471  PAINTWINDOW,  line 123 of include/customcontrol.inc
  $0059BB7B  PAINTHANDLER,  line 4857 of include/wincontrol.inc
  $005A00A4  WMPAINT,  line 6851 of include/wincontrol.inc
  $005B3330  WMPAINT,  line 103 of include/customcontrol.inc
  $004103A1
  $0059D0A7  WNDPROC,  line 5429 of include/wincontrol.inc
  $007A6B0F  WNDPROC,  line 6399 of synedit.pp
FreeFormEditor: FormEditor1=TFormEditor
Hint: (lazarus) [TMainIDE.Destroy] B  -> inherited Destroy... TMainIDE
Hint: (lazarus) [TMainIDE.Destroy] END
Heap dump by heaptrc unit of i:\FPC\lazarus\lazarus.exe
6222427 memory blocks allocated : 556846869/572547168
6211889 memory blocks freed : 555436555/571105040
10538 unfreed memory blocks : 1410314
True heap size : 28114944 (128 used in System startup)
True free heap : 25543392
Should be : 25661040
Call trace for block $1CEE6DD0 size 64
  $00418EBF
  $770034A1
  $77003473
  $76FB0133
  $00C11C76  PAINTLINES,  line 1799 of lazsyntextarea.pp
  $00C11847  PAINTTEXTLINES,  line 1871 of lazsyntextarea.pp
  $00C113D8  DOPAINT,  line 1489 of lazsyntextarea.pp
  $00C07EA0  PAINT,  line 1308 of syneditmiscclasses.pp
  $00C0FDD2  DOPAINT,  line 1134 of lazsyntextarea.pp
  $00C07EA0  PAINT,  line 1308 of syneditmiscclasses.pp
  $00D9A022  DOPAINT,  line 1353 of sourcesyneditor.pas
  $00C07EA0  PAINT,  line 1308 of syneditmiscclasses.pp
  $0079ECCB  PAINT,  line 4221 of synedit.pp
  $005B3471  PAINTWINDOW,  line 123 of include/customcontrol.inc
  $0059BB7B  PAINTHANDLER,  line 4857 of include/wincontrol.inc
  $005A00A4  WMPAINT,  line 6851 of include/wincontrol.inc
Call trace for block $1C6FECD0 size 92

--
Best regards,
 Maxim Ganetsky  mailto:gan...@narod.ru
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to list available serial ports on Linux?

2020-10-06 Thread Wolf via lazarus
By submitting your question to DuckDuckGo, I found 
https://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them


To quote:

|To see which tty's are currently in use, you can simply look into the 
file /proc/tty/drivers: and get a rather short list of devices. |Does it help?



||

On 7/10/20 10:35 AM, Bo Berglund via lazarus wrote:

Is there a way to list the available (working) serial ports on a Linux
platform like the RaspberryPi?

I would like to offer a dropdown list of working serial ports to the
user to select among, but I am dissuaded from it when I do the
following:

ls -la /dev/tty*
It returns a very long list of serial devices and most of these are
probably not even existing in real life.

On an RPi I get
/dev/tty
/dev/ttyN (where N=0..63
/dev/ttyAMA0 <== This is RPi Serial0 port on the pin header.
/dev/ttyprintk
and:
/dev/ttyUSB0../dev/ttyUSB3 depending on what is plugged into USB

All in all about 70 devices, but not sure which are actually available
for use.

Is this an impossible task or can one check for "live" serial ports
only? If so how?

On Windows I have ported a convoluted function from Delphi, which uses
Registry reads to give me the list.


-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] How to list available serial ports on Linux?

2020-10-06 Thread Bo Berglund via lazarus
Is there a way to list the available (working) serial ports on a Linux
platform like the RaspberryPi?

I would like to offer a dropdown list of working serial ports to the
user to select among, but I am dissuaded from it when I do the
following:

ls -la /dev/tty*
It returns a very long list of serial devices and most of these are
probably not even existing in real life.

On an RPi I get
/dev/tty
/dev/ttyN (where N=0..63
/dev/ttyAMA0 <== This is RPi Serial0 port on the pin header.
/dev/ttyprintk
and:
/dev/ttyUSB0../dev/ttyUSB3 depending on what is plugged into USB

All in all about 70 devices, but not sure which are actually available
for use.

Is this an impossible task or can one check for "live" serial ports
only? If so how?

On Windows I have ported a convoluted function from Delphi, which uses
Registry reads to give me the list.


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Win 7 issue / Re: -dWINDOWS_LIGATURE [[Re: Font ligatures support]]

2020-10-06 Thread Martin Frb via lazarus

On 06/10/2020 15:09, Maxim Ganetsky via lazarus wrote:



Can you try to catch it in the debugger, and see what params are given
to NewTextOut
in
#2  0x00ab95f6 in DRAWHILIGHTMARKUPTOKEN (ATOKENINFO=...,
parentfp=0x13abf6e8)
 at lazsyntextarea.pp:1741

  fTextDrawer.NewTextOut(TxtLeft, rcToken.Top, TxtFlags, tok,
ATokenInfo.Tk.TokenStart, ATokenInfo.Tk.TokenLength, FEtoBuf);
Can you add some debugln in a format convenient to you? This will
simplify things, I think.

This is in the paint handler, and it is called for each token. So 
potentially very slow with debugln.


But since it is in startup, hopefully you wont have to many.

Apply this patch please

diff --git a/components/synedit/lazsyntextarea.pp 
b/components/synedit/lazsyntextarea.pp

index 4c5a599c9b..163af24e6c 100644
--- a/components/synedit/lazsyntextarea.pp
+++ b/components/synedit/lazsyntextarea.pp
@@ -1737,6 +1737,7 @@ procedure TLazSynTextArea.PaintTextLines(AClip: 
TRect; FirstLine, LastLine,

 if rcToken.Right > nRightEdge + 1 then
   tok.Bottom := rcLine.Bottom;
 TxtLeft := ScreenColumnToXValue(ATokenInfo.PhysicalCharStart); // 
because for the first token, this can be middle of a char, and lead to 
wrong frame
+debugln('Calling NewTextOut L: %s rcT: %s tok: %s tkt: %s // %s // eto: 
%s', [dbgs(TxtLeft), dbgs(rcToken), dbgs(tok), 
dbgMemRange(PByte(ATokenInfo.Tk.TokenStart), ATokenInfo.Tk.TokenLength), 
dbgs(ATokenInfo.Tk.TokenLength), dbgs(Length(FEtoBuf.EtoData)) ]);

 fTextDrawer.NewTextOut(TxtLeft, rcToken.Top, TxtFlags, tok,
   ATokenInfo.Tk.TokenStart, ATokenInfo.Tk.TokenLength, FEtoBuf);

diff --git a/components/synedit/syntextdrawer.pp 
b/components/synedit/syntextdrawer.pp

index 834d442563..ddbb09f4df 100644
--- a/components/synedit/syntextdrawer.pp
+++ b/components/synedit/syntextdrawer.pp
@@ -1267,9 +1267,14 @@ procedure TheTextDrawer.NewTextOut(X, Y: Integer; 
fuOptions: UINT;

 CharPlaceInfo.lpGlyphs:= @Glyphs[0];
 CharPlaceInfo.nGlyphs:= Length(Glyphs);
 Glyphs[0] := #0;
+debugln('BEFORE');
 if GetCharacterPlacementW(FDC, PWChar(W), Length(W), 0, 
CharPlaceInfo, GCP_LIGATE or GCP_REORDER or GCP_GLYPHSHAPE)<> 0 then begin
+debugln('GOT PLACEMENT %s  / %s  / %s', [dbgs(length(Glyphs)), 
dbgs(CharPlaceInfo.nGlyphs), dbgs(CharPlaceInfo.lpGlyphs=@Glyphs[0]) ]);

+if CharPlaceInfo.nGlyphs > 0 then begin
+debugln('GOT --- %s  / %s', [dbgs(length(Glyphs)), 
dbgMemRange(CharPlaceInfo.lpGlyphs, 2*CharPlaceInfo.nGlyphs)]);
   Windows.ExtTextOutW(FDC, X, Y, fuOptions or ETO_GLYPH_INDEX, 
@ARect, Pointer(Glyphs), CharPlaceInfo.nGlyphs, EtoArray);

   exit;
+end;
 end;
   end;
   {$ENDIF}

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Win 7 issue / Re: -dWINDOWS_LIGATURE [[Re: Font ligatures support]]

2020-10-06 Thread Maxim Ganetsky via lazarus


06.10.2020 13:32, Martin Frb via lazarus пишет:
> On 06/10/2020 01:01, Maxim Ganetsky via lazarus wrote:
>> 05.10.2020 18:36, Martin Frb via lazarus пишет:
>>> On 05/10/2020 00:27, Maxim Ganetsky via lazarus wrote:
 Lazarus hangs on start for me on Windows 7 when compiled with this
 define.

 Lazarus 2.1.0 r63957 FPC 3.2.0 i386-win32-win32/win64. I use
 JetBrains Mono font.

>>>
>>> The other ...TextOut in the lines below that should be kept as they are.
>>
>> This change does not help.
> 
> Ok, I installed Win7 in a virtualbox, got Lazarus, installed the
> "JetBrains mono" font (just the regular, skipped all the
> light/italics) and "JetBrains mono Variable".
> 
> No crash.
> Ligatures work (well the subset as described in other mail)
> 
> Without any way of reproducing, there isn't much I can do.
> 
> 
> Can you try to catch it in the debugger, and see what params are given
> to NewTextOut
> in
> #2  0x00ab95f6 in DRAWHILIGHTMARKUPTOKEN (ATOKENINFO=...,
> parentfp=0x13abf6e8)
> at lazsyntextarea.pp:1741
> 
>  fTextDrawer.NewTextOut(TxtLeft, rcToken.Top, TxtFlags, tok,
> ATokenInfo.Tk.TokenStart, ATokenInfo.Tk.TokenLength, FEtoBuf);

Can you add some debugln in a format convenient to you? This will
simplify things, I think.

-- 
Best regards,
 Maxim Ganetsky  mailto:gan...@narod.ru
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] -dWINDOWS_LIGATURE [[Re: Font ligatures support]]

2020-10-06 Thread Martin Frb via lazarus

On 04/10/2020 18:05, Martin Frb wrote:

On 04/10/2020 10:14, Mr Bee wrote:
If it does work, would you please submit it as a patch for the next 
release? At least, add a note that the font ligatures feature only 
supports monospaced fonts and only works on Windows. It's better than 
nothing.



revision 63951

Windows only, compile with -dWINDOWS_LIGATURE
Tested with Cascadia.


I did add a couple of checks. Amended it for right to left languages 
(Arabic).


Arabic only works with certain fonts.
And Japanese Katakana seems not to work at all (or I have not found a 
supporting font, while without this feature it works with "Deja Vue" and 
others).


It appears that this API restricts Windows font substitution abilities.
It might be that in order for all this to work, one has to use the newer 
"uniscribe" API.


I also kind of assume that in the current IFDEF code the use of the DX 
array (ETO) is wrong. But I could not produce any errors from that / And 
it only would happen if  NeedETO = True.


So for the moment, this stays highly experimental.

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] @Alexey length(Glyph) [[Re: Font ligatures support]]

2020-10-06 Thread Martin Frb via lazarus

On 03/10/2020 16:34, Alexey Tor. via lazarus wrote:

It's not very simple. see file
https://github.com/Alexey-T/ATSynEdit/blob/master/atsynedit/atsynedit_canvasproc.pas 

and search for "ligatures" in all places. Unit has special code for 
win32.


Just a note

    if GetCharacterPlacementW(DC, PWChar(Str), Length(Str), 0, 
@CharPlaceInfo, GCP_LIGATE)<> 0 then
  Result:= Windows.ExtTextOutW(DC, X, Y, ETO_CLIPPED or ETO_OPAQUE 
or ETO_GLYPH_INDEX, Rect, Pointer(Glyphs), Length(Glyphs), Dx)


Should that be
  CharPlaceInfo.nGlyphs
instead of
  Length(Glyphs)
?

GetCharacterPlacementW may return up to (but therefore also less than)  
Length(Glyphs) glyphs.

So ExtTextOutW should get the adjusted count?




--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Win 7 issue / Re: -dWINDOWS_LIGATURE [[Re: Font ligatures support]]

2020-10-06 Thread Martin Frb via lazarus

On 06/10/2020 01:01, Maxim Ganetsky via lazarus wrote:

05.10.2020 18:36, Martin Frb via lazarus пишет:

On 05/10/2020 00:27, Maxim Ganetsky via lazarus wrote:
Lazarus hangs on start for me on Windows 7 when compiled with this 
define.


Lazarus 2.1.0 r63957 FPC 3.2.0 i386-win32-win32/win64. I use 
JetBrains Mono font.




The other ...TextOut in the lines below that should be kept as they are.


This change does not help.


Ok, I installed Win7 in a virtualbox, got Lazarus, installed the 
"JetBrains mono" font (just the regular, skipped all the 
light/italics) and "JetBrains mono Variable".


No crash.
Ligatures work (well the subset as described in other mail)

Without any way of reproducing, there isn't much I can do.


Can you try to catch it in the debugger, and see what params are given 
to NewTextOut

in
#2  0x00ab95f6 in DRAWHILIGHTMARKUPTOKEN (ATOKENINFO=..., 
parentfp=0x13abf6e8)

at lazsyntextarea.pp:1741

 fTextDrawer.NewTextOut(TxtLeft, rcToken.Top, TxtFlags, tok, 
ATokenInfo.Tk.TokenStart, ATokenInfo.Tk.TokenLength, FEtoBuf);


--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] -dWINDOWS_LIGATURE [[Re: Font ligatures support]]

2020-10-06 Thread Alexey Tor. via lazarus

-> => >= <= *** .. ... <> >< >> << >>> <<< == !=

Visual Studio shows all as ligatures except the first one 


It's trivial - synedit just doesn't TextOut such symbols in one block, 
ie it doesn't renders '->' as 2 chars but renders it as 2 chars - and >. 
Same for >>> and <<< etc.


--
Regards,
Alexey

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus