Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Bo Berglund
On Wed, 21 Jun 2017 01:57:36 +0200, José Mejuto
 wrote:

>> The problem I have is that it seems only to work for COM1 or COM3, as
>> soon as I use a higher numbered port like COM33 then it fails.
>> What have I missed here?
>> Is serial only able to work with the low numbered ports (single
>> digit)?
>
>COM ports in windows can only be 1-9, to open high numbered COM ports 
>you must use the extended name syntax (without quotes) "\\.\COM99" you 
>can also use "\\.\COM1" for COM1-9.

It turns out that I also must not use the trailing colon in the name
which is present in the wiki example...
But then I get a non-zero handle. I have yet to verify that data can
flow.

Is there a way to enumerate the available com ports so that they can
be listed in a combobox for selection? This would have the advantage
that it would work on both Windows and Linux and it limits the
possible errors by the user. Of course the enumerator must know about
the differences in syntax between Windows and Linux!

What about Linux (Raspberry Pi)? Is the com port name simply ttyUSB1
or do I have to use the full /dev/ttyUSB1?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread José Mejuto

El 21/06/2017 a las 1:37, Bo Berglund escribió:


The problem I have is that it seems only to work for COM1 or COM3, as
soon as I use a higher numbered port like COM33 then it fails.
What have I missed here?
Is serial only able to work with the low numbered ports (single
digit)?


Hello,

COM ports in windows can only be 1-9, to open high numbered COM ports 
you must use the extended name syntax (without quotes) "\\.\COM99" you 
can also use "\\.\COM1" for COM1-9.



--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Bo Berglund
On Tue, 20 Jun 2017 09:18:50 +, Mark Morgan Lloyd
 wrote:

>
>I tend to use the lower-level serial.pp unit. The patches I contributed 
>a couple of years ago specifically added a couple of read-with-timeout 
>functions.

I'm back with a question:
I used the serial example in the hardware access wiki:
http://wiki.freepascal.org/Hardware_Access#FPC_built_in_Serial_unit

as a template and I have a button on my form to open/close the serial
port, but it does not work properly. Below is my button code to open
and close the port depending on the state it is in, which is set by
the global boolean var FComOpen.
The port number is taken from a spinedit speComPort and the baud rate
is from a preloaded combobox cbxBaud:

procedure TForm1.btnConnectComClick(Sender: TObject);
begin
  if FComOpen then
  begin
//Close com port
SerSync(FComH); { flush out any remaining before closure }
SerFlushOutput(FComH); { discard any remaining output }
SerClose(FComH);
FComOpen := false;
TButton(Sender).Caption:= 'Open Serial';
ledSerial.Brush.Color:= clRed;
  end
  else
  begin
//Open com port
FComPortName := 'COM' + IntToStr(speComPort.Value) + ':';
FComFlags := [ ];
FBaud := StrToInt(cbxBaud.Text);
FComH := SerOpen(FComPortName);
if FComH <> 0 then
begin
  FComOpen := true;
  SerSetParams(FComH,FBaud,8,NoneParity,1,FComFlags);
  TButton(Sender).Caption:= 'Close Serial';
  ledSerial.Brush.Color:= clLime;
end;
  end;
end;

The problem I have is that it seems only to work for COM1 or COM3, as
soon as I use a higher numbered port like COM33 then it fails.
What have I missed here?
Is serial only able to work with the low numbered ports (single
digit)?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] ptccrt missing keys

2017-06-20 Thread Nikolay Nikolov



On 06/13/2017 02:56 AM, James Richters wrote:

please be patient, it'll get there, maybe in a few week's time

I will be happy to be patient   Thank you for all your hard work on this!
Ok, I've implemented implemented this. ptccrt now has a KeyMode 
variable, which can be set to these values:


kmTP7 - behaves like Turbo Pascal 7's CRT unit under DOS. This is the 
default value. Previous versions of ptccrt always behaved this way. 
Since TP7's CRT unit doesn't support the Enhanced Keyboard, several keys 
(e.g. F11 and F12) and key combinations are intentionally not recognized 
for compatibility reasons.
kmGO32 - behaves like Free Pascal's CRT unit under DOS (GO32V2). It has 
Enhanced Keyboard support.
kmFPWINCRT - behaves like Free Pascal's CRT unit under Windows. Similar 
to kmGO32, but emulates several incompatibilities that the Windows CRT 
unit has with the GO32V2 CRT unit. Not all of them are emulated though, 
since some of them can be considered bugs.


I've also committed this into FPC trunk and I've proposed it to be 
merged into FPC 3.0.4, so please test and report any bugs that you found. :)


Enjoy!
Nikolay
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Bo Berglund
On Tue, 20 Jun 2017 09:18:50 +, Mark Morgan Lloyd
 wrote:

>I tend to use the lower-level serial.pp unit. The patches I contributed 
>a couple of years ago specifically added a couple of read-with-timeout 
>functions.
>
Mark, thanks for your input!

I had a look at the serial unit and I found that there are two
overloaded functions SerReadTimeout():

function SerReadTimeout(Handle: TSerialHandle; var Buffer; mSec:
LongInt): LongInt;

function SerReadTimeout(Handle: TSerialHandle; var Buffer: array of
byte; count, mSec: LongInt): LongInt;

In the second of them there is a count argument, presumably indicating
the number of bytes to read from the port. The first is missing this
but sets the value to 1 in the call to ReadFile.

Does this mean that it will only read a single byte and return it
whereas the second version reads the indicated number of bytes and
then returns?
I assume that for both there is a return forced when the timeout
expires.
In both cases the number of actually read bytes are returned in the
result.

Questions:
--
Do I have to create a thread in order to constantly monitor the state
of the reception?
And I could not find a way to set the comm buffer size, what happens
if I do not check incoming data for a while when there is an inbound
stream. Is there an overflow somewhere?

Anyway it looks promising so far, now I just have to find the proper
TCP client component to use as the far end of the link.
I have used Indy components in the past but I would like something a
bit simpler to use...


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Implementing AggPas with PtcGraph

2017-06-20 Thread Graeme Geldenhuys

On 2017-06-20 11:17, James Richters wrote:

That will be a great help.   Might I suggest mentioning the existence
and use of Agg2D in agg_2D and vice versa?  Something like:


Ah yes, I forgot about that. I'll add it now.



I also think you have made enough changes to it to warrant version
number changes.


After moving AggPas into the fpGUI repository, I don't consider it a 
separate "project" as such - even though it can still be used 
independent from fpGUI. So the original AggPas version numbering is of 
no concern to me any more, it will now follow the versions of fpGUI itself.


The unit header comment does mention that I forked it from the original 
2.4 RM3 AggPas, but that things diverged from there.




I'm also strongly considering renaming the "render/software/"
directory to "render/aggpas/". I'll mull this over for another day
or two.


I like the proposed directory name.  I wonder if it really needs 2
directories, why not just render-aggpas/ or aggpas-render/  ?


The 2 part directory names is because other Canvas renderers will and 
can be added to fpGUI. eg: Locally I already have a user contributed 
Cairo canvas renderer which lives in the "render/cairo/" directory, but 
has not been made public yet in the Github/SourceForge repositories. 
This is also why I think I should rename the "render/software/" 
directory to "render/aggpas/" - it makes things much clearer.


I'm also thinking of refactoring the X11 and GDI canvas rendering code, 
so they too live in the "render/*" directory hierarchy.


I also know of a user that is working on a OpenGL renderer for fpGUI.



Since there are going to be changes that require adjustments anyway,
I wonder if it would make sense to just make agg_2D always require
the pixel format in the constructor:

constructor Agg2D.Construct_PF(pixfmt:define_pixfmt);

It seems the original intention of aggpas was to have this
flexibility but somewhere along the way things like rgba ended up
getting hard coded into it.


A very good point. I'll make a note to commit those changes too.



Better off to just fix it then fix any programs as needed instead of
having an even bigger and more confusing mess that no one will
remember why it's like that in 5 years.


Exactly!



Regards,
  Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Paulo Costa

On 20-Jun-17 10:45, Michael Schnell wrote:

On 20.06.2017 11:18, Mark Morgan Lloyd wrote:
I tend to use the lower-level serial.pp unit. The patches I 
contributed a couple of years ago specifically added a couple of 
read-with-timeout functions


IMHO, freeing the user from the necessity to poll or do a thread to wait 
for serial events is a very beneficial strategy.


But Koenraad Lelong said in the other mail that "SDPOSerial" has a 
OnRxData event. Hopefully by "event" a main thread event is meant.


Yes. That is the case.

Paulo Costa
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Michael Schnell

On 20.06.2017 11:18, Mark Morgan Lloyd wrote:
I tend to use the lower-level serial.pp unit. The patches I 
contributed a couple of years ago specifically added a couple of 
read-with-timeout functions


IMHO, freeing the user from the necessity to poll or do a thread to wait 
for serial events is a very beneficial strategy.


But Koenraad Lelong said in the other mail that "SDPOSerial" has a 
OnRxData event. Hopefully by "event" a main thread event is meant.


-Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Mark Morgan Lloyd

On 20/06/17 06:45, Michael Schnell wrote:

On 18.06.2017 18:16, Bo Berglund wrote:> No RS232 work with FPC/Lazarus>
earlier and in Delphi I used AsyncPro components, but these are so>
complex that one is lost amongst all properties to set...AsyncPro is
free and easy to use but not perfectly bug-free.
Unfortunately no fpc/Lazarus port yet.


I tend to use the lower-level serial.pp unit. The patches I contributed 
a couple of years ago specifically added a couple of read-with-timeout 
functions.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Serial to TCP gateway in FPC?

2017-06-20 Thread Michael Schnell



On 18.06.2017 18:16, Bo Berglund wrote:

No RS232 work with FPC/Lazarus
earlier and in Delphi I used AsyncPro components, but these are so
complex that one is lost amongst all properties to set...

AsyncPro is free and easy to use but not perfectly bug-free.

Unfortunately no fpc/Lazarus port yet.

-Michael
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal