Re: [Lazarus] Translating a small C program to pascal (on lazarus)

2018-02-25 Thread Carlos E. R. via Lazarus
On 2018-02-26 01:11, Giuliano Colla via Lazarus wrote:
> Il 25/02/2018 20:52, Carlos E. R. via Lazarus ha scritto:
> 
>> I want to translate a little Linux C program (600 lines) to pascal (so
>> that I can then add my parts in comfort). I failed to find a good
>> automated tool in Linux. I had a look here: 
> 
> Did you consider h2pas (which comes with fpc/Lazarus)?
> It's only intended to translate C headers to Pascal, but it makes a good
> job on this.
> 
> You can only use it to translate declarations, but once declarations are
> in Pascal, converting the code becomes much easier.

Ah!  I didn't realize it could translate the declarations on a .c file,
I thought it was only for .h files.

I just had a quick test, but... I'll have to read on it, the quick test
crashes:

cer@Telcontar:~/bin/lazarus/mios/egctl> h2pas egctl.c
at line 49 error : syntax error
at line 82 error : syntax error
An unhandled exception occurred at $004089F2:
EAccessViolation: Access violation
  $004089F2

cer@Telcontar:~/bin/lazarus/mios/egctl>

It did some translation, though:

-rw-r--r-- 1 cer users   0 Feb 26 03:36 ext2.tmp
-rw-r--r-- 1 cer users   0 Feb 26 03:36 ext.tmp
-rw-r--r-- 1 cer users1579 Feb 26 03:36 ext3.tmp


The last file contains a translation till it crashed:


{$include }
...
  const
TASK_LEN = 4;
STATCRYP_LEN = 4;
CTRLCRYP_LEN = 4;
KEY_LEN = 8;
...
SOCKET_COUNT = 4;
(* error
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
in define line 49 *)


type
  Protocol = (EG_PROTO_V20,EG_PROTO_V21,EG_PROTO_WLAN
);

  Action = (ACTION_ON,ACTION_OFF,ACTION_TOGGLE,ACTION_LEFT,
ACTION_INVALID);

  Actions = record
  socket : array[0..(SOCKET_COUNT)-1] of Action;
end;

  Key = record
  octets : array[0..(KEY_LEN)-1] of uint8_t;
end;
{ since the protocol is little-endian, low word comes first  }


and here it crashes.

-- 
Cheers / Saludos,

Carlos E. R.
(from 42.2 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Translating a small C program to pascal (on lazarus)

2018-02-25 Thread Giuliano Colla via Lazarus

Il 25/02/2018 20:52, Carlos E. R. via Lazarus ha scritto:

I want to translate a little Linux C program (600 lines) to pascal (so 
that I can then add my parts in comfort). I failed to find a good 
automated tool in Linux. I had a look here: 


Did you consider h2pas (which comes with fpc/Lazarus)?
It's only intended to translate C headers to Pascal, but it makes a good 
job on this.


You can only use it to translate declarations, but once declarations are 
in Pascal, converting the code becomes much easier.


Giuliano

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


Re: [Lazarus] Translating a small C program to pascal (on lazarus)

2018-02-25 Thread Carlos E. R. via Lazarus
On 2018-02-25 21:26, Mark Morgan Lloyd via Lazarus wrote:
> On 25/02/18 20:00, Carlos E. R. via Lazarus wrote:


>> Hi,
>> I want to translate a little Linux C program (600 lines) to pascal (so
>> that I can then add my parts in comfort). I failed to find a good
>> automated tool in Linux. I had a look here:
>> 
>> I used "OpenC2Pas" but there remains quite a lot to translate.
> 
> etc. Presumably the original looks something like
> https://github.com/unterwulf/egctl/blob/master/egctl.c

Absolutely! :-)

How did you find out that fast?

> I've just been through a comparable exercise writing a utility to
> program a Logitech G600 gamer's mouse, and my suggestion would be to use
> Wireshark etc. to get an understanding of the messages going over the
> network then to transcribe the bits of the program you need into Pascal
> manually.

I don't think I have the skill set for that. I guess that the author of
that code, Vitaly Sinilin, had the Windows SDK for the device (a power
strip controllable and programmable via Ethernet, LAN or WAN) and did a
translation to Linux of the Windows command line tool. The SDK comes
with the CD when purchasing the power strip, but the box I bought on
Amazon had none. Perhaps it can be downloaded for free (I did not look
yet), but anyway, it is for Windows (and probably C).

> Assuming that since you're asking on the Lazarus ML you're putting
> together a GUI to control the device you probably won't want roughly
> half of the original code which is using C-style string operations to
> read a configuration file.

No, I'm not writing a GUI, I'm attempting to write a daemon. :-)

I have a router that hangs randomly, and I can't replace it because it
is ISP supplied with a complex configuration. So the idea is to ping the
router and when it goes silent power cycle it. I have tested the idea, I
can power a socket off from Linux using that utility, and then a
programmed schedule switches it back on on the 00 seconds mark (the
power strip syncs via NTP). The period can be programmed to anything,
but currently it is set to every minute.

So first I have to handle that powering off some seconds before the "00"
mark, then I have to add the ping, wait for router come back alive, log
the event, update the dynamic dns, email me, and go back to watch.

Of course, I could do it all from a bash script, maybe easier. But I
want to have a go at doing it in Pascal first. :-)


The funny thing is, I programmed for a living in C two decades ago, I
was good. It seems I fave forgotten most of it. :-}


I hopped to find people here familiar with C to pas translation. I also
did this type of things long ago... I translated some windows api
headers to pascal back then.

-- 
Cheers / Saludos,

Carlos E. R.
(from 42.2 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Translating a small C program to pascal (on lazarus)

2018-02-25 Thread Mark Morgan Lloyd via Lazarus

On 25/02/18 20:00, Carlos E. R. via Lazarus wrote:

-BEGIN PGP SIGNED MESSAGE-Hash: SHA1

Hi,
I want to translate a little Linux C program (600 lines) to pascal (so 
that I can then add my parts in comfort). I failed to find a good 
automated tool in Linux. I had a look here:


I used "OpenC2Pas" but there remains quite a lot to translate.


etc. Presumably the original looks something like 
https://github.com/unterwulf/egctl/blob/master/egctl.c


I've just been through a comparable exercise writing a utility to 
program a Logitech G600 gamer's mouse, and my suggestion would be to use 
Wireshark etc. to get an understanding of the messages going over the 
network then to transcribe the bits of the program you need into Pascal 
manually.


Assuming that since you're asking on the Lazarus ML you're putting 
together a GUI to control the device you probably won't want roughly 
half of the original code which is using C-style string operations to 
read a configuration file.


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

[Opinions above are the author's, not those of his employers or colleagues]
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] fpreport designer

2018-02-25 Thread patspiper via Lazarus

On 25/02/18 21:09, Michael Van Canneyt via Lazarus wrote:

On Sun, 25 Feb 2018, patspiper via Lazarus wrote:

Hi,

I am able to create fpreports by code.

However the graphical designer is riddled with serious bugs making it 
impossible to use. I haven't succeeded in creating a single report. 
Is something wrong with my installation, or is the designer still in 
alpha stage? I'll create bug reports if it's the latter case.


Hm. I don't know your installation of course, so it is hard to comment 
on that.


But you should definitely be able to make reports. I know I do. But 
then, I made it, so I will probably avoid doing things that confuse 
the designer...


If you do experience bugs, please report them, I will do my best to 
fix them ASAP.


I use FPC 3.0.5 with fpreport from trunk along with lazarus trunk.

Just to test the waters:

1- Create a new application
2- Place a TFPReport on the form
3- Double click the FPReport component to open the designer
4- Add a page by clicking the add page toolbutton
-> Bug1: The page properties are not displayed in the designer's object 
inspector

5- Add a databand and enlarge it
6- Click on memo toolbutton
7- Click on the databand without dragging. The memo will be created with 
0 size.

8- Resize the memo with the mouse
-> Bug2: The designer freezes and cannot be closed anymore

If you can confirm these 2 bugs, i'll start creating bug reports in the 
tracker.


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


Re: [Lazarus] fpreport designer

2018-02-25 Thread Michael Van Canneyt via Lazarus



On Sun, 25 Feb 2018, patspiper via Lazarus wrote:


Hi,

I am able to create fpreports by code.

However the graphical designer is riddled with serious bugs making it 
impossible to use. I haven't succeeded in creating a single report. Is 
something wrong with my installation, or is the designer still in alpha 
stage? I'll create bug reports if it's the latter case.


Hm. 
I don't know your installation of course, so it is hard to comment on that.


But you should definitely be able to make reports. I know I do. 
But then, I made it, so I will probably avoid doing things that confuse the designer...


If you do experience bugs, please report them, I will do my best to fix them 
ASAP.

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


Re: [Lazarus] TImage drag of big image

2018-02-25 Thread AlexeyT via Lazarus

I now see it's not needed in TImage, it must be component TScrollbox+TImage.
sorry.

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


[Lazarus] fpreport designer

2018-02-25 Thread patspiper via Lazarus

Hi,

I am able to create fpreports by code.

However the graphical designer is riddled with serious bugs making it 
impossible to use. I haven't succeeded in creating a single report. Is 
something wrong with my installation, or is the designer still in alpha 
stage? I'll create bug reports if it's the latter case.


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


Re: [Lazarus] Form events firing order and count

2018-02-25 Thread José Mejuto via Lazarus

El 25/02/2018 a las 9:03, Gabor Boros via Lazarus escribió:

For me the good order is the real order independently from the other 
widgetsets. For example at form maximize, the form moved to 0,0 
coordinates then it's size increased. At form restore, form's size 
decreased then moved to the correct place. So at maximize the order is 
moved, resized, statechanged and at restore resized, statechanged, moved.


Hello,

Events order is mostly a matter of taste, for me the order should be 
statechange (so programmer can cancel the operation before it happens, 
if possible), move, resize.


Is the development process of LCL-fpGUI public or viewable just when 
committed into Lazarus trunk?


I'm the only one working in LCL-fpGUI and I'm contributing using patches 
so the "advances" are not visible in real-time. If you are interested in 
the advances I can pack my develop folder and send it to you by mail 
when something more or less important is changed. The folder is mostly 
in unstable state because some features need a lot of try/error with a 
bunch of writelns all over different units.


Last advance is Hi-DPI support (under testing) and the possibility to 
compile with develop branch but with this branch some things do not work 
as expected (I think they are bugs in fpGUI and I'm writting sample code 
to send to Graeme so he can decide if its a bug or not).


--

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