Re: [fpc-pascal] USB Human Interface Devices

2019-08-21 Thread Johann Glaser
Hi!

Am Montag, den 19.08.2019, 18:22 -0400 schrieb James Richters:
> Oh, for some reason I wasn't thinking I was replacing mydevice.pas
> with snapi.pas...   Ok.. so if
> I understand this correctly,  make the changes necessary in snapi.pas
> to use libusboop.pas instead of the old usb.pas, and then use
> TSNAPIDevice.Create to create a TLIBUSBPseudoHIDInterface to my
> device? ... and that will allow me a more generic method to access
> the device?

Hmm, no. You should make your own unit for your device, from scratch.
And then use snapi.pas as a guide how to do that. As I've written in my
previous EMail:

--- schnipp ---
You really should create your own class descending from TLibUsbDevice
(instead of TLibUsbDeviceWithFirmware).

In your constructor, you have to get a reference to the HID interface
of your device, e.g., by
  TLibUsbPseudoHIDInterface.Create(...)
analogous to
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/examples/mydevice.pas#L141
.

This internally also gets references to the necessary endpoints,
therefore you most probably don't need manual FInterface.FindEndpoint()
(like TMyDevice).

--- schnapp ---

But please pay attention to the new methods, parameters, ...

Bye
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-19 Thread Johann Glaser
Hi!

Am Sonntag, den 18.08.2019, 10:43 -0400 schrieb James Richters:
> I just pushed it.

Sorry for the delayed reply.

After comparing the exception stack trace you've sent (see below) and
your code, the access violation happens at
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/libusboop.pas#L1330
. The code dereferences the parameter AEndpoint.

Most probably it is however Nil, because the preceding
FInterface.FindEndpoint(EP_IN) in
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/examples/mydevice.pas#L143
didn't find that endpoint.

As I've written, TMyDevice is NOT a generic device! It is specific for
EZ-USB chips. You really should create your own class descending from
TLibUsbDevice (instead of TLibUsbDeviceWithFirmware).

In your constructor, you have to get a reference to the HID interface
of your device, e.g., by
  TLibUsbPseudoHIDInterface.Create(...)
analogous to
https://github.com/Zaaphod/pas-libusb/blob/Hack/src/examples/mydevice.pas#L141
.

This internally also gets references to the necessary endpoints,
therefore you most probably don't need manual FInterface.FindEndpoint()
(like TMyDevice).

Please see snapi.pas, which I've sent you on 2019-08-10. This does
exactly that. I've sent this file specifically that you use it instead
of mydevice.pas.

Bye
  Hansi


> > Could you please "git push" the source code to Github so that the
> > line numbers match the output? At least in line 1330 of
> > libusboop.pas there is no Create. Please ensure that the
> > version on Github is the very same version where you executed the
> > program and got the line numbers.
>
> Thanks
>   Hansi
>
> > Running "i:\programming\pas-
> > libusb_test_dll\src\examples\testopendevic_vidpid2.exe "
> > start
> > 1
> > 2
> > a05472131
> > a10CEEB93
> > b
> > c
> > FALSE  8086  10CE  A36D  EB93
> > FALSE  8087  10CE  0AAA  EB93
> > FALSE  0424  10CE  2734  EB93
> > FALSE  1D50  10CE  6015  EB93
> > FALSE  1B1C  10CE  0C15  EB93
> > TRUE  10CE  10CE  EB93  EB93
> > FALSE  05E3  10CE  0610  EB93
> > FALSE  04E8  10CE  61F5  EB93
> > FALSE  1B1C  10CE  0C10  EB93
> > FALSE  0424  10CE  274C  EB93
> > FALSE  047D  10CE  1020  EB93
> > FALSE  1B1C  10CE  1B4F  EB93
> > FALSE  1A40  10CE  0101  EB93
> > FALSE  0C45  10CE  7403  EB93
> > FALSE  10C4  10CE  EA60  EB93
> > d
> > e
> > N
> > P
> > L
> > H1
> > I
> > I2
> > Q
> > R
> > K
> > M
> > O1
> > An unhandled exception occurred at $00010002D0BB:
> > EAccessViolation: Access violation
> >   $00010002D0BB  CREATE,  line 1330 of libusboop.pas
> >   $00010002B3AB
> >   $00011942  main,  line 75 of ../../pas-
> > libusb_test_dll/src/examples/testopendevic_vidpid2.pas
> >   $00011AF6  main,  line 96 of ../../pas-
> > libusb_test_dll/src/examples/testopendevic_vidpid2.pas
> >   $000100010040
> >   $000117F0
> >   $7FFB66D07E94
> >   $7FFB675FA251
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-18 Thread Johann Glaser
Hi!

Am Samstag, den 17.08.2019, 18:00 -0400 schrieb James Richters:
> I commented out all the try & except stuff and ran it.. I get this
> output:

Could you please "git push" the source code to Github so that the line
numbers match the output? At least in line 1330 of libusboop.pas there
is no Create. Please ensure that the version on Github is the very same
version where you executed the program and got the line numbers.

Thanks
  Hansi

> Running "i:\programming\pas-
> libusb_test_dll\src\examples\testopendevic_vidpid2.exe "
> start
> 1
> 2
> a05472131
> a10CEEB93
> b
> c
> FALSE  8086  10CE  A36D  EB93
> FALSE  8087  10CE  0AAA  EB93
> FALSE  0424  10CE  2734  EB93
> FALSE  1D50  10CE  6015  EB93
> FALSE  1B1C  10CE  0C15  EB93
> TRUE  10CE  10CE  EB93  EB93
> FALSE  05E3  10CE  0610  EB93
> FALSE  04E8  10CE  61F5  EB93
> FALSE  1B1C  10CE  0C10  EB93
> FALSE  0424  10CE  274C  EB93
> FALSE  047D  10CE  1020  EB93
> FALSE  1B1C  10CE  1B4F  EB93
> FALSE  1A40  10CE  0101  EB93
> FALSE  0C45  10CE  7403  EB93
> FALSE  10C4  10CE  EA60  EB93
> d
> e
> N
> P
> L
> H1
> I
> I2
> Q
> R
> K
> M
> O1
> An unhandled exception occurred at $00010002D0BB:
> EAccessViolation: Access violation
>   $00010002D0BB  CREATE,  line 1330 of libusboop.pas
>   $00010002B3AB
>   $00011942  main,  line 75 of ../../pas-
> libusb_test_dll/src/examples/testopendevic_vidpid2.pas
>   $00011AF6  main,  line 96 of ../../pas-
> libusb_test_dll/src/examples/testopendevic_vidpid2.pas
>   $000100010040
>   $000117F0
>   $7FFB66D07E94
>   $7FFB675FA251
>
>
>
>
> > > Could you please remove the try-except block in
> > > testopendevic_vidpid2.pas and compile with debug line info to get
> > > the full exception backtrace incl. line numbers?
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-17 Thread Johann Glaser
Hi!

Am Samstag, den 17.08.2019, 16:16 +0200 schrieb Jean SUZINEAU:
> Le 17/08/2019 à 15:00, James Richters a écrit :
> > Function TLibUsbInterface.FindEndpoint(MatchFunc :
> > TLibUsbEndpointMatchMethod) : Plibusb_endpoint_descriptor;
> > MatchFunc(ED) is where the access violation occurs, but I can’t
> > trace any further because I can’t find the function MatchFunc()   I
> > just don’t understand where the actual function is.
>
> MatchFunc is a parameter (its type is TLibUsbEndpointMatchMethod) of
> TLibUsbInterface.FindEndpoint.
> To find which function is actually called, you should trace back
> where TLibUsbInterface.FindEndpoint is called and what function is
> provided as parameter MatchFunc.
> It's likely you'll have to "climb up" through several calls, may be
> that TLibUsbInterface.FindEndpoint has itself a parameter MatchFunc
> If you use the debugger, the callstack and a breakpoint just before
> the offending call to MatchFunc should help you to find from where
> comes your MatchFunc.
> I wouldn't be surprised that it resolves somewhere to an overridden
> method Match of an instance of a class derived from
> TLibUsbDeviceMatchClass, likely TLibUsbDeviceMatchVidPid.Match,
> TLibUsbDeviceMatchVidPidSerial.Match or
> TLibUsbInterfaceMatchNumAlt.Match from unit libusbutil.pas
> This can sound difficult  for you at the beginning if you're not too
> much accustomed with variables of type procedure and inheritance, but
> after a few practice it's not that complicated.

Thanks Jean for the explanation! The MatchFunc is a so called
"callback". I've chosen this pattern to allow to implement flexible
filter functions when searching for devices, interfaces, endpoints, ...

As far as I can see, you are using TMyDevice in mydevice.pas. This unit
is specifically implemented for the EZ-USB chips (Cypress AN2131),
which do not have Flash or ROM, but only SRAM. The driver has to
download the firmware before the real communication. This specific
behavior is demonstrated in mydevice.pas. Therefore it is only of
limited use for your device.

One action of TMyDevice.Create is to open an interface and then two
bulk endpoints (see lines 141-145 in your "Hack" branch. The interface
can be opened (hence you see an 'e' in your output. Then wants to open
the endpoint 2 (line 143) using
TLibUsbInterface.FindEndpoint(bEndpointAddress : Byte) at
libusboop.pas:1099. This calls via some detours the function where
you've added the WriteLns.

Actually all these functions should reside cleanly in the Pascal world
and there are no calls to libusb functions, therefore I wouldn't expect
any calling convention troubles here.

Could you please remove the try-except block in
testopendevic_vidpid2.pas and compile with debug line info to get the
full exception backtrace incl. line numbers?

Thanks
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-13 Thread Johann Glaser
Hi James!

Am Montag, den 12.08.2019, 20:20 -0400 schrieb James Richters:
> > > Ah, I see. You declared EP as Plibusb_endpoint_descriptor (i.e.,
> > > the pointer to an endpoint descriptor record), while in the
> > > original code it is a USBEndpointDescriptor (i.e., the record
> > > itself).
> > > Your version is more memory efficient but uses "ugly pointer-
> > > arithmetic" by taking the address of an array element. However,
> > > just keep it as you implemented it.
>
> Well that wasn’t my idea,  I was trying to get it to compile and I
> saw the existing function:
> // helper function for method below, this can't be a local function
> Function
> MyEndpointMatch(EP:Plibusb_endpoint_descriptor;Data:Pointer):Boolean;
> Var bEndpointAddress : Byte;
> Begin
>   bEndpointAddress := (PtrUInt(Data) shr 0) and $FF;
>   Result := (EP^.bEndpointAddress = bEndpointAddress);
> End;
>
>   It compiled and had the pointer, so I stuck a pointer in the
> one I was having a problem with and it compiled it was just a
> guess at how to get it to compile honestly. I figured that the other
> code had it so maybe something to do with the way things are defined
> now require it to be a pointer.. without the pointer it gives errors.

Yes, yes, no worries! That was no criticism, just a (hopefully)
objective description of what I saw in the code. :-)

> > > While reviewing your changes, I found a few small things.
> > > Could you please keep the indenting and coding style as the
> > > existing code? This is especially for the constant and type
> > > declarations around TLibUsbPseudoHIDInterface (IIRC the
> > > >>keywords Type and Const should start at character 1, therefore
> > > you also should un-indent the 6+3 constants and the P/THIDReport
> > > record (except its final "End;" by 2 spaces.
>
>   Yes, I will keep the indenting and coding style the same, No
> problem, I adjusted this as you requested.  I'll go through later and
> see if there are any other things I missed.. most of what I've done
> is cutting and pasting, but I'll keep it consistent.

Great, thanks! And there is no hurry.

> > > Secondly, in your improved TLibUsbInterface.FindEndpoint, please
> > > revert the capitalization and indenting changes (i.e., capital
> > > "Function", "For", ..., and "do" and "then" in the same line, ...
> > > IMHO the only changed lines in comparison to the original code
> > > should be the extra variable EP, its assignment without range
> > > checks, and its use in MatchFunc and Exit.
> That was code the Jean sent me to get it to work under windows, but I
> wend an retrieved the original function and re-did the modifications
> to match the formatting.  It compiles fine without turning off range
> check, but I think there was some reason why Jean had to put them in
> there.. I'll leave it out for now unless we figure out why they were
> needed.

You can just keep in the range checking. I think I should have done
this from the beginning, but never used range checking, therefore never
thought of it.

> > > And thirdly, you introduced a class type
> > > TLibUsbInterruptInEndpoint, which is IMHO unused. If its so,
> > > please remove it. I like to avoid clutter. :-)
>   I guess you are talking about line
> 128:   TLibUsbInterruptInEndpoint   = class; ?
>   When I copied over { TUSBPseudoHIDInterface } and then
> renamed everything I needed it to be able to compile
>   Line 211:FIntrEndpoint : TLibUsbInterruptInEndpoint;
>   Without it I was getting libusboop.pas(212,21) Error:
> Identifier not found "TLibUsbInterruptInEndpoint"
>   So I went back to usb.pas and copied that line over to
> prevent this error... perhaps I have it in the wrong place??

Let me have a closer look. :-)

Ah, sorry, it was my fault. I should have looked at the complete file,
not just the diff. :-)

Please keep the forward declaration in.

> > > Apart form these cosmetic things, thank you very much for your
> > > effort!
>   No problem,  please let me know if I missed anything,  I'm
> happy to make it conform to the coding standards.  I’m a little
> confused by the capitalization, for example sometimes it's
> LibUsb,  sometimes it's Libusb.. I'm trying to figure out when the U
> is capitated and when it is not maybe it should always be one way
> or the other?  Please continue to correct me on anything you see.

That's probably my own lazyness. However, at least in libusboop.pas,
all declarations use LibUsb (capital 'U') everywhere. And in libusb.pas
its "libusb" (all small letters) except the unit name itself.

> > > I'm looking forward hearing from you your success when accessing
> > > a HID device (or call for help :-) ).
>
>   Well. since you asked... I'm having a real challenge trying
> to figure out how I can use all this to access my device... I'm just
> not familiar with this kind of programming... constructors,
> destructors, and all this inherited stuff, it's not what I am used
> t

Re: [fpc-pascal] USB Human Interface Devices

2019-08-12 Thread Johann Glaser
Hi!

Am Sonntag, den 11.08.2019, 19:13 -0400 schrieb James Richters:
> Thank you for the help.  I made most of the changes you recommend and
> I was able to get it to compile,  the only one I had trouble with was
> If I take out the ^ from:
>if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
>  LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>   (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> then
>
> So it looks like this:
>if (EP.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
>  LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>   (EP.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> then
>
> I get a compiler error:
> libusboop.pas(1168,14) Error: Illegal qualifier
> libusboop.pas(1168,14) Fatal: Syntax error, ")" expected but
> "identifier BMATTRIBUTES" found
> libusboop.pas(0) Fatal: Compilation aborted
>
> With the ^ in it compiles anyway... I don't know how to adjust the
> format to not have the ^
>
> I have not tried to do anything with TLibUsbPseudoHIDInterface yet, I
> was just trying to get libusboop.pas to compile, and be able to still
> run the previous examples.
>
> I've updated my repository at
> https://github.com/Zaaphod/pas-libusb/tree/Test
>
> Let me know if I should do something different with the ^ above, or
> if you see anything else I missed.

Ah, I see. You declared EP as Plibusb_endpoint_descriptor (i.e., the
pointer to an endpoint descriptor record), while in the original code
it is a USBEndpointDescriptor (i.e., the record itself).

Your version is more memory efficient but uses "ugly pointer-
arithmetic" by taking the address of an array element. However, just
keep it as you implemented it.

While reviewing your changes, I found a few small things.

Could you please keep the indenting and coding style as the existing
code? This is especially for the constant and type declarations around
TLibUsbPseudoHIDInterface (IIRC the keywords Type and Const should
start at character 1, therefore you also should un-indent the 6+3
constants and the P/THIDReport record (except its final "End;" by 2
spaces.

Secondly, in your improved TLibUsbInterface.FindEndpoint, please revert
the capitalization and indenting changes (i.e., capital "Function",
"For", ..., and "do" and "then" in the same line, ... IMHO the only
changed lines in comparison to the original code should be the extra
variable EP, its assignment without range checks, and its use in
MatchFunc and Exit.

And thirdly, you introduced a class type TLibUsbInterruptInEndpoint,
which is IMHO unused. If its so, please remove it. I like to avoid
clutter. :-)

Apart form these cosmetic things, thank you very much for your effort!
I'm looking forward hearing from you your success when accessing a HID
device (or call for help :-) ).

Thanks
  Hansi

> -Original Message-
> From: fpc-pascal  On Behalf
> Of Johann Glaser
> Sent: Sunday, August 11, 2019 4:16 PM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> Hi!
>
> Am Samstag, den 10.08.2019, 17:50 -0400 schrieb James Richters:
> > I'm making an attempt to copy TUSBPseudoHIDInterface into
> > libusboop.pas.  I've made the recomended name changes and then
> > tried
> > to compile it.  Some things I found like the names changing from
> > things like
> >
> > PUSBInterfaceDescriptop to Plibusb_interface_descriptor
>
> OK, there are two things. Names directly from libusb-1.0 (as used in
> libusb.pas) should be identical to the original C code, i.e.,
> Plibusb_interface_descriptor as you've written.
>
> The second thing are the classes in the OOP wrapper in libusboop.pas.
> Please use CamelCase for them, e.g., TLibusbPseudoHIDInterface.
>
> > are pretty obvious, but just taking a guess on other things like:
> >
> >  changing:
> >   if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK =
> > USB_ENDPOINT_TYPE_INTERRUPT) and
> >  (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then
> >
> > To:
> >   if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
> > LIBUSB_TRANSFER_TYPE_INTERRUPT) and
> >  (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> > then
>
> Yes, very good, thanks!
>
> Whether EP is a pointer (--> EP^.bmAttributes) or a record
> (EP.bmAttributs) just depends on the usage in the code. As I see in
> usb.pas in line 846, in TUSBPseudoHIDInterface.Create, it is actually
> the record, so you should stay without the '^'.
>
> > Based on looking at something similar in libusbutil... but I'm not
> > sure it's right at all I'm not sur

Re: [fpc-pascal] USB Human Interface Devices

2019-08-11 Thread Johann Glaser
Hi!

Am Samstag, den 10.08.2019, 17:50 -0400 schrieb James Richters:
> I'm making an attempt to copy TUSBPseudoHIDInterface into
> libusboop.pas.  I've made the recomended name changes and then tried
> to compile it.  Some things I found like the names changing from
> things like
>
> PUSBInterfaceDescriptop to Plibusb_interface_descriptor

OK, there are two things. Names directly from libusb-1.0 (as used in
libusb.pas) should be identical to the original C code, i.e.,
Plibusb_interface_descriptor as you've written.

The second thing are the classes in the OOP wrapper in libusboop.pas.
Please use CamelCase for them, e.g., TLibusbPseudoHIDInterface.

> are pretty obvious, but just taking a guess on other things like:
>
>  changing:
>   if (EP.bmAttributes and USB_ENDPOINT_TYPE_MASK =
> USB_ENDPOINT_TYPE_INTERRUPT) and
>  (EP.bEndpointAddress and USB_ENDPOINT_DIR_MASK <> 0) then
>
> To:
>   if (EP^.bmAttributes and LIBUSB_TRANSFER_TYPE_MASK =
> LIBUSB_TRANSFER_TYPE_INTERRUPT) and
>  (EP^.bEndpointAddress and LIBUSB_ENDPOINT_DIR_MASK <> 0)
> then

Yes, very good, thanks!

Whether EP is a pointer (--> EP^.bmAttributes) or a record
(EP.bmAttributs) just depends on the usage in the code. As I see in
usb.pas in line 846, in TUSBPseudoHIDInterface.Create, it is actually
the record, so you should stay without the '^'.

> Based on looking at something similar in libusbutil... but I'm not
> sure it's right at all I'm not sure if USB_ENDPOINT_TYPE_MASK was
> really changed to LIBUSB_TRANSFER_TYPE_MASK or if something else
> happened.  But at least it compiles...

You translated it correctly.

> but now I've hit a few items that I just don't know what to do
> with.I can't find anything similar to get a reference from:
>
> libusboop.pas(1198,28) Error: Identifier not found "USB_TYPE_CLASS"

Use LIBUSB_REQUEST_TYPE_CLASS.

> libusboop.pas(1199,5) Error: Identifier not found
> "USB_REQ_HID_SET_REPORT"
> libusboop.pas(1216,27) Error: Identifier not found "USB_TYPE_CLASS"
> libusboop.pas(1217,5) Error: Identifier not found
> "USB_REQ_HID_GET_REPORT"
> libusboop.pas(1227,23) Error: Identifier not found
> "HID_REPORT_TYPE_OUTPUT"

Please copy the constants USB_REQ_HID_* and HID_REPORT_* from
libusb.pas (branch master) lines 248-257 to the interface section of
libusboop.pas (branch libusb-1.0) directly above the class declaration
of TLibusbPseudoHIDInterface. Then please rename USB_REQ_HID_* to
LIBUSB_REQUEST_HID_* and HID_REPORT_* to LIBUSB_HID_REPORT_*.

> I've tried things that seem to be in line with other changes, like
> changing USB_Type_Class to LIBUSB_TYPE_CLASS or spelling out REQUEST
> instead of REQ which also seems to be done in other places, but still
> the identifiers are not found... the problem is I have no idea where
> these identifiers were/are defined.
>
> I made a fork in github and a branch called "test"  here:
> https://github.com/Zaaphod/pas-libusb/tree/Test

Great approach, thanks, then we can use pull requests.

Thanks
  Hansi

> > Actually you could copy the class TUSBPseudoHIDInterface (plus the
> > types THIDReport and TIntrReportFunc) from usb.pas to libusboop.pas
> > and change everything necessary.
> > At least one difference is that all names change from TUSB* to
> > TLibUsb*. I'm sure there are more, but I don't know by heart.
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-09 Thread Johann Glaser
Hi!

Am Freitag, den 09.08.2019, 08:08 -0400 schrieb James Richters:
> Hi Hansi,
> Thanks for the explanation.
>
> Here's the python code I’m trying to port over to FPC:
> https://github.com/wolfmanjm/kivy-smoothie-host/blob/master/modules/hb04.py
>
> it uses functions like hid.open, hid.close, hid.read, hid.write, and
> hid.send_feature_report   I'm trying to figure out how to somehow get
> similar functions to those in FPC.   Some example of how to perform
> those kinds of functions would be extremely helpful!

These hid.open, hid.close, ... functions are all methods of the object
"hid", which was previously assigned to from devices[0] (line 68),
which itself was returned from en.find(), where en is an object of
Enumeration() from the package easyhid.

To communicate with USB HID devices, please peek into the outdated
branch “master” of pas-libust (for legacy libusb-0.1) and open file
src/usb.pas. This is the old analogous to the new libusboop.pas.

It has the class TUSBPseudoHIDInterface which implements basic
communication with USB HID devices.

I've used that for a project with a barcode scanner. Please find
attached the two files snapi.pas (implementing the "standard" SNAPI for
barcode scanners, which is based on USB HID), and
barcodescannersymbolms4407.pas (implementing a few more specific
methods for a Symbol MS4407 barcode scanner). The latter file uses
several units of my project, therefore it will not compile on your
host. It is just to see how to use the SNAPI devices. I release these
files with the same license as libusboop.pas.

Please excuse that these files are still based on the outdated pas-
libusb for the old libusb-0.1. Therefore they would need translation
for the newer libusb-1.0 stuff. Unfortunately I've never head time to
transition the project. Actually you could copy the class
TUSBPseudoHIDInterface (plus the types THIDReport and TIntrReportFunc)
from usb.pas to libusboop.pas and change everything necessary.

At least one difference is that all names change from TUSB* to
TLibUsb*. I'm sure there are more, but I don't know by heart.

Please also excuse that I can’t recall why its just “PseudoHID” and not
a fully-fledged HID. Probably I didn’t implement all HID functions, or
the SNAPI HID interface just isn't registered with descriptor type $21.

This brings me to the second topic, where you got the message
  Unknown descriptor type $21 with length 9
from test2controlsync. That's a HID descriptor (see LIBUSB_DT_HID). It
is just not decoded in test2controlsync.

And finally, the third point regarding the bug with PortPath index.
I've fixed that now and pushed to Github. Thanks for pointing this out!

Thanks
  Hansi

> -Original Message-
> From: fpc-pascal  On Behalf
> Of Johann Glaser
> Sent: Friday, August 9, 2019 7:17 AM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> Hi!
>
> Just a quick reply while at work, I'll reply to all EMails in the
> evening.
>
> First of all: Thanks for finding the bug with the index variable I
> vs. J. I'll fix that in the evening.
>
> Secondly: You are correct, the "EZ-USB" is a specific chip family by
> Cypress, e.g., AN2131, without Flash/ROM but with SRAM for the
> firmware. I built a few devices with that chip, therefore I also
> implemented the Pascal "driver" to download the firmware into the
> "naked" device. There are also many (old) devices on the marked which
> use that chip, e.g., the Keil uLink (1st generation).
>
> To understand how USB actually works (endpoints, in and out
> transfers, control/bulk/interrupt/isochronous transfers, ...), I have
> learned a lot from the Technical Reference Manual (TRM) of the EZ-
> USB. Just search for it, there are plenty of sources. Chapter 1 is
> the interesting one. If you directly search at the Cypress page, they
> will redirect you to the successor product FX2, but its chapter 1 is
> nearly identical to that of EZ-USB.
>
> The EZ-USB firmware download is performed with control transfers to
> EP0. So you can find examples for control transfers in ezusb.pas.
>
> You can find example code for bulk and interrupt endpoints e.g., in
> https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas.
>
> I can provide more examples in the evening.
>
> Bye
>   Hansi
>
> > Gesendet: Freitag, 09. August 2019 um 12:09 Uhr
> > Von: "James Richters" 
> > An: "'FPC-Pascal users discussions'" <
> > fpc-pascal@lists.freepascal.org>
> > Betreff: Re: [fpc-pascal] USB Human Interface Devices
> >
> > Maybe I am going down the wrong path trying to get
> > test_arduino_with_bmp280.pas to work with my device...  I think I
>

Re: [fpc-pascal] USB Human Interface Devices

2019-08-09 Thread Johann Glaser
Hi!

Just a quick reply while at work, I'll reply to all EMails in the evening.

First of all: Thanks for finding the bug with the index variable I vs. J. I'll 
fix that in the evening.

Secondly: You are correct, the "EZ-USB" is a specific chip family by Cypress, 
e.g., AN2131, without Flash/ROM but with SRAM for the firmware. I built a few 
devices with that chip, therefore I also implemented the Pascal "driver" to 
download the firmware into the "naked" device. There are also many (old) 
devices on the marked which use that chip, e.g., the Keil uLink (1st 
generation).

To understand how USB actually works (endpoints, in and out transfers, 
control/bulk/interrupt/isochronous transfers, ...), I have learned a lot from 
the Technical Reference Manual (TRM) of the EZ-USB. Just search for it, there 
are plenty of sources. Chapter 1 is the interesting one. If you directly search 
at the Cypress page, they will redirect you to the successor product FX2, but 
its chapter 1 is nearly identical to that of EZ-USB.

The EZ-USB firmware download is performed with control transfers to EP0. So you 
can find examples for control transfers in ezusb.pas.

You can find example code for bulk and interrupt endpoints e.g., in 
https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas.

I can provide more examples in the evening.

Bye
  Hansi

> Gesendet: Freitag, 09. August 2019 um 12:09 Uhr
> Von: "James Richters" 
> An: "'FPC-Pascal users discussions'" 
> Betreff: Re: [fpc-pascal] USB Human Interface Devices
>
> Maybe I am going down the wrong path trying to get 
> test_arduino_with_bmp280.pas to work with my device...  I think I am 
> confusing easyusb with easyhid which is what is used to communicate with the 
> device in the python code I am trying to use.  It looks like easyusb is to 
> send firmware to a specific usb device that has no rom in it... and that's 
> not exactly what I'm trying to do...
>
> I'm trying to figure out how to open the device and read data and write data 
> to this device.  Is there an example of how to do that with pas-libusb?
>
> Sorry I am so confused by all this.  I feel like I'm almost to where I will 
> understand things again but I'm just missing something.
>
> James
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] USB Human Interface Devices

2019-08-08 Thread Johann Glaser
Hi!

Am Donnerstag, den 08.08.2019, 13:14 +0200 schrieb Jean SUZINEAU:
> Le 08/08/2019 à 12:07, James Richters a écrit :
>
> > Is the static linking issue just with Windows, and it works on
> > Linux, or it isn’t working with FPC at all on either?
> >
> > James
>
> It seems that right out of the box pas-libusb uses static linking for
> me.

I think you meant to write "dynamic linking" here. :-) When I use the
Makefile, it also uses dynamic linking. Actually, I've never tried to
do static linking with libusb, because dynamic linking works so
flawlessly on Linux.

Bye
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-06 Thread Johann Glaser
Hi!

Am Dienstag, den 06.08.2019, 01:35 +0200 schrieb Jean SUZINEAU:
> Hello
> I haven't had time yet to read
>   everything but I join below a few more tests.
>
>
> Le 05/08/2019 à 21:38, Johann Glaser a
>   écrit :
>
>
>
> >
> >   Yay! That looks great!
> >
> >
> >
> >   As a next step you can try test2controlsync.pas
> > which uses control transfers to query the device
> > descriptors.
> > Just change the constants DevVID
> > and DevPID at the top to
> > the values of a device connected to your PC. I'd recommend
> > to
> > use a device you don't depend on during testing, i.e.,
> > don't use
> > your primary keyboard and mouse.  There shouldn't be a
> > problem, but better safe than
> > sorry. And I hope that Windows doesn't cross your plans and
> > already has allocated that device to a certain driver.
> >
> >
> >
> >   You can also try test3controlasync.pas,
> > which does a very similar test, just using the asynchronous
> > interface to libusb (and it is less verbose and estensive).
> >
> >
> >
> >
>
> I tested successfully test2controlsync and test3controlasync on
>   Windows 10 and Ubuntu 19.04 with a Seeeduino lotus (recognized
> as
>   manufacturer Silicon Labs, Product CP2102N USB to UART Bridge
>   Controller).
> I've zipped the code in a new "convenience release" at :
>
>
>
> https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/pas-libusb_convenience_release_2
> This is the output on Windows:
> E:\03_travail\libusb\pas-
> libusb_test_dll\src\examples>test2controlsync.exeBus 001 Device 010:
> ID 10C4:EA60Device
> Descriptor:  bLength18  bDescriptorType 1  bc
> dUSB   2.00  bDeviceClass0  bDeviceSubClass
>0  bDeviceProtocol 0  bMaxPacketSize064  idVen
> dor$10C4  idProduct   $EA60  bcdDevice
>  1.00  iManufacturer   1 Silicon
> Labs  iProduct2 CP2102N USB to UART Bridge
> Controller  iSerialNumber   3
> 0001  bNumConfigurations  1  Configuration
> Descriptor:bLength 9bDescriptorType 2
> wTotalLength   32bNumInterfaces  1bConfig
> urationValue 1iConfiguration  0bmAttributes
> $80MaxPower  100mAInterface
> Descriptor:  bLength 9  bDescriptorType
>4  bInterfaceNumber0  bAlternateSetting   0
>bNumEndpoints   2  bInterfaceClass   255  bInt
> erfaceSubClass  0  bInterfaceProtocol  0  iInterface
>  0  Endpoint
> Descriptor:bLength 7bDescriptorType
>5bEndpointAddress  $02  EP 2
> OUTbmAttributes2  Transfer
> TypeBulk  Synch
> Type   None  Usage
> Type   DatawMaxPacketSize  $0040  1x 64
> bytesbInterval   0  Endpoint
> Descriptor:bLength 7bDescriptorType
>5bEndpointAddress  $82  EP 2
> INbmAttributes2  Transfer
> TypeBulk  Synch
> Type   None  Usage
> Type   DatawMaxPacketSize  $0040  1x 64
> bytesbInterval   0
> E:\03_travail\libusb\pas-
> libusb_test_dll\src\examples>test3controlasync.exeSubmitting control
> transferFinished Transfer, Data = 38, Status = 0, ActualLength =
> 18Device
> Descriptor:  bLength18  bDescriptorType 1  bc
> dUSB   2.00  bDeviceClass0  bDeviceSubClass
>0  bDeviceProtocol 0  bMaxPacketSize064  idVen
> dor$10C4  idProduct   $EA60  bcdDevice
>  1.00  iManufacturer   1  iProduct2  iSerialN
> umber   3  bNumConfigurations  1Done.
> E:\03_travail\libusb\pas-libusb_test_dll\src\examples>
>
>

Thats great, it works! Then have fun with all further experiments. If
you need help, just ping me.
Bye  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-05 Thread Johann Glaser
Hi Jean!

Am Sonntag, den 04.08.2019, 17:20 +0200 schrieb Jean SUZINEAU:
> Hi Hansi,
>
>
>
> Le 04/08/2019 à 14:05, Johann Glaser a
>   écrit :
>
>
>
>
> >   Thanks for your effort and please excuse my late reply, I was
> > busy thelast few days.
> >
>
> With pleasure.
>
> test1library.pas from branch
>   "libusb-1.0" worked nearly out of the box.
>
>
>
>   I nearly just needed to redefine extdecl from stdcall to cdecl
> as
>   in Linux.
>
>
>
>   I copied (libusb-1.0.22)\MinGW64\dll\libusb-1.0.dll of 274 Ko
> to
>   (pas-libusb branch libusb-1.0)\src\examples.
>
>   In libusb.pas I removed {$LINKLIB c} and changed {$LINKLIB
>   usb-1.0} to {$LINKLIB libusb-1.0.dll}
>
>   I join my diff files. Lazarus made a few changes to
>   test1library.lpi but I don't think they are important.

Amazing, thanks for trying and giving feedback!

So, from my perspective, your results and modifications are the same as
those of Vitaly at
  https://github.com/hansiglaser/pas-libusb/issues/4

Referring to your EMail to James, it seems that Vitaly even got it
working with static linking. Especially "$LINKLIB msvcrt" and "$LINKLIB
usb-1.0.dll.a" look promising. Hmm, OTOH he writes of dynamically
linked, I don't know.

Could you please also have a look at his comments in that Github issue?

>   I verified, test1library can be build with this command line:
>
> C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.exe
>   -MObjFPC -Scghi -O1 -g -gl -l -vewnhibq -Filib\x86_64-win64
> -Fu..
>   -Fu. -FUlib\x86_64-win64 -FE. -otest1library.exe
> test1library.pas
>
>
>
> (eventually you need to create
>   subdirectory lib\x86_64-win64 by hand)
>
> Upon execution, I got this results:
>
> :\03_travail\libusb\pas-libusb\src\examples>test1library.exeUsing
> libusb(x) v1.0.22.11312Found 13 devices:  Bus   1 Device  15: ID
> 10C4:EA60,  port:  14, port path from HCD: 0, Speed: 12 Mbit/s (USB
> FullSpeed)  Bus   1 Device  12: ID 28DE:2101,  port:   7, port path
> from HCD: 0->11->11, Speed: 12 Mbit/s (USB FullSpeed)  Bus   1
> Device   0: ID 8086:A2AF,  port:   0, Speed: Unknown  Bus   1
> Device  10: ID 0BB4:2C87,  port:   5, port path from HCD: 0->5->5,
> Speed: 12 Mbit/s (USB FullSpeed)  Bus   1 Device   9: ID
> 0BB4:2C87,  port:   2, port path from HCD: 0->0->0, Speed: 480 Mbit/s
> (USB HighSpeed)  Bus   1 Device   4: ID 1C4F:0002,  port:   7, port
> path from HCD: 0, Speed: 1.5 Mbit/s (USB LowSpeed)  Bus   1
> Device   2: ID 046D:C077,  port:   8, port path from HCD: 0, Speed:
> 1.5 Mbit/s (USB LowSpeed)  Bus   1 Device   8: ID
> 28DE:2000,  port:   1, port path from HCD: 0->1->1, Speed: 12 Mbit/s
> (USB FullSpeed)  Bus   1 Device   7: ID 0BB4:0306,  port:   2, port
> path from HCD: 0->33, Speed: 12 Mbit/s (USB FullSpeed)  Bus   1
> Device  11: ID 28DE:2101,  port:   6, port path from HCD: 0->128-
> >128, Speed: 12 Mbit/s (USB FullSpeed)  Bus   1 Device   5: ID
> 07CA:A110,  port:   5, port path from HCD: 0, Speed: 480 Mbit/s (USB
> HighSpeed)  Bus   1 Device   6: ID 0BB4:2134,  port:   1, port path
> from HCD: 0->0, Speed: 480 Mbit/s (USB HighSpeed)  Bus   1
> Device   1: ID 0BB4:2210,  port:  11, port path from HCD: 0, Speed:
> 480 Mbit/s (USB HighSpeed)
> E:\03_travail\libusb\pas-libusb\src\examples>

Yay! That looks great!

As a next step you can try test2controlsync.pas which uses control
transfers to query the device descriptors. Just change the constants
DevVID and DevPID at the top to the values of a device connected to
your PC. I'd recommend to use a device you don't depend on during
testing, i.e., don't use your primary keyboard and mouse. :-) There
shouldn't be a problem, but better safe than sorry. And I hope that
Windows doesn't cross your plans and already has allocated that device
to a certain driver.

You can also try test3controlasync.pas, which does a very similar test,
just using the asynchronous interface to libusb (and it is less verbose
and estensive).

For trying real custom communication (e.g., to bulk endpoints) you
would need an appropriate USB device. For example at
https://github.com/hansiglaser/pas-gpib/blob/master/usb/usbtmc.pas
I've implemented communication with electrical measurement devices
(GPIB via USB). Somewhere on my harddisk I should have a driver for a
barcode reader. And also drivers for a few devices built by myself. If
you are interested or have questions, I can provide some sources too.

Bye
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-04 Thread Johann Glaser
Hi James!

Am Donnerstag, den 01.08.2019, 22:45 -0400 schrieb James Richters:
> I understand it better now, but I've been out of town and haven't
> been able to work on it.   I'm not sure what is meant by installing
> development packages though.. I see libusb at https://libusb.info/ I
> see where to download that.. but I don't know about development
> packages?  As for LibC,   I'm not really sure where to find the
> proper package for that.  I found
> http://gnuwin32.sourceforge.net/packages/libc.htm.bak but I'm not
> sure that is right, and again not sure about development package for
> that.  I would really appreciate links to the exact packages I will
> need to use for Windows.

I'm sorry that I can't help you here with these Windows-specific
questions.

Could somebody else please help out here?

Thanks
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-04 Thread Johann Glaser
Hi Jean!

Thanks for your effort and please excuse my late reply, I was busy the
last few days.

Please note that for pas-libusb there is a dedicated Git branch for the
newer LibUSB 1.0. The branch is called "libusb-1.0". Marc pointed to
that in his EMail from Fri, 26 Jul 2019 15:56:17 +0200.

I'm sorry for the confusion! I've now updated the Readme.rst in the
branch "master" to point that out.

In the branch "libusb-1.0" I've lately changed a few things (see my
EMail from Tue, 30 Jul 2019 22:54:07 +0200) so that all dependencies to
Linux units should be gone.

Actually, with the branch "libusb-1.0" you should not need any "compat"
stuff any more.

Could you please give that a try and see whether you are more
successful with it?

Regarding "lsusb": The "test1library.pas" example should be just that.

Regarding the testfirmware example: This is specifically for devices
with the EZUSB Chip (e.g., Cypress AN2131). It is included to
demonstrate, how you could implement your own interface to your own
device with other chips with SRAM firmware (e.g. Cypress FX2 or FX3).

Bye
  Hansi

Am Sonntag, den 04.08.2019, 08:54 +0200 schrieb Jean SUZINEAU:
> Zadig
>
> I found a way to make  my test with libusb-win32 work. You just need
> to install a specific driver for the usb device you want to see.
> This can be done using Zadig ( https://zadig.akeo.ie/ ). If you
> change the driver to "libusbK" or "libusb-win32" for a certain device
> with Zadig, it will appear with lsusb_libusb-win32\lsusb.exe .
> But it doesn't change anything for the version with libusb-compat,
> lsusb_libusb-compat-msys2_mingw64\lsusb.exe wich shows nothing.
> And it doesn't change anything either to the version with libusb,
> https://github.com/jsuzineau/pascal_o_r_mapping/releases/tag/2019_08_03_lsusb
> which continue to show all the usb devices.
>
> I have also tried libusbK (
> http://libusbk.sourceforge.net/UsbK3/index.html ).
> You can download it at  https://sourceforge.net/projects/libusbk/
>
> There are delphi examples in the subdirectory
> bindings\examples_delphi .
>
> They can be compiled easily with freepascal, you just need to compile
> in delphi mode.
> For "bindings\examples_delphi\enumerate.dpr" you can use this command
> line ( from a cmd in the directory examples_delphi)
>C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.exe -MDelphi -Scghi -O1
> -g -gl -l -vewnhibq -Filib\x86_64-win64 -Fu. -FUlib\x86_64-win64 -FE.
> -oenumerate.exe enumerate.dpr
>
> For "bindings\examples_delphi\opendevice.dpr" it didn't found unit
> UExampleHelpers. I didn't investigated further but it seems you can
> find the unit at :
> https://github.com/SimaWB/libusbkDelphi/blob/master/UExampleHelpers.pas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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


Re: [fpc-pascal] USB Human Interface Devices

2019-08-01 Thread Johann Glaser
Hi!

Am Dienstag, den 30.07.2019, 19:57 -0400 schrieb James Richters:
> Thanks for removing the un-needed units.  I have been trying to
> compile as-is without any modifications.   I was not aware that this
> was dependent on LibC and Lib-USB.  I am not really clear on how to
> install these, maybe I just need to download the correct files and
> have them in the same directory I am trying to compile Pas-LibUSB
> from?
> I quite literally have a stock installation of FPC3.0.4RC1 and that
> is all.. nothing else, no Lazarus, no LibC or LibUSB anything
> development or otherwise.   So it seems the first step will be to
> install the prerequisite packages.  I'll see if I can figure that
> out.

Yes, pas-libusb is a Pascal wrapper for the Linux library libusb. That
library itself further depends on libc. Thats why you have to install
them, and including their respective development packages.

Was the message of Jean helpful for you?

Thanks
  Hansi

> -Original Message-
> From: fpc-pascal  On Behalf
> Of Johann Glaser
> Sent: Tuesday, July 30, 2019 4:54 PM
> To: fpc-pascal@lists.freepascal.org
> Subject: Re: [fpc-pascal] USB Human Interface Devices
>
> Hi James!
>
> Am Dienstag, den 30.07.2019, 13:52 -0400 schrieb James Richters:
> > > > Due to my lack of understanding of Windows, I've not yet taken
> > > > over his changes, because I wanted to wait for confirmation
> > > > from
> > > > other users. So if James had some feedback, I'd appreciate it
> > > > greatly.
> >
> > I'm trying to get this to work on windows,  I'm having a lot of
> > units
> > not found errors when I try to compile anything at all.. I'm not
> > sure
> > what I need here to get the examples to work.Here is a list of
> > units I can't find when I try to compile with FPC 3.0.4RC1 on
> > Windows:
> >
> > ezusb.pas(42,15) Fatal: Can't find unit Errors used by EZUSB I have
> > no
> > idea what Unit Errors is or what it might be for.
>
> Thanks for pointing this out. This is a Unix unit, but it is
> obviously not used in Ezusb. I've removed it now.
>
> > libusb.pas(1350) Warning: Library c.dll not found, Linking may fail
> > !■
> > libusb.pas(1350) Warning: Library usb-1.0 not found, Linking may
> > fail !
> > I'm not really following where c.dll and usb1.0 are supposed to
> > come
> > from
>
> It seems you didn't install the development stuff for libc and lib-
> usb?
> At least in Linux, I always have to install these additionally (e.g.,
> libusb-1.0-0-dev) to the "productive" libraries (e.g., libusb-1.0-0).
>
> > usb.pas(31,22) Fatal: Can't find unit Baseunix used by USB
>
> Same as above for Errors. However, this file is unused.
>
> > mydevice.pas(27,20) Fatal: Can't find unit BaseUnix used by
> > MyDevice I
> > have no idea what BaseUnix does or if I can do something windows
> > compatible instead somehow.
>
> Same as above for Errors.
>
> > Test1Library.pas:
> > ║ (0) Error: Import library not found for c ║ (0) Error: Import
> > library not found for usb-1.0
>
> This seems to be again a problem because of the missing development
> stuff for libc anc libusb.
>
> > To be honest this is quite a bit over my head.  I'm trying to
> > follow
> > https://github.com/hansiglaser/pas-libusb/issues/4 but I'm just
> > lost.
>
> I would recommend, first to just compile the pristine pas-libusb
> without any hints from that Github issue. Only if you get the same
> errors, please try them and let me know.
>
> As stated above, I've now removed all references to the units Errors
> and Baseunix. Please "git pull" to the newest state on Github and
> compile again. If you still face problems, please don't hesitate to
> ask again.
>
> Thanks
>   Hansi
>
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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


Re: [fpc-pascal] USB Human Interface Devices

2019-07-30 Thread Johann Glaser
Hi James!

Am Dienstag, den 30.07.2019, 13:52 -0400 schrieb James Richters:
> > > Due to my lack of understanding of Windows, I've not yet taken
> > > over his changes, because I wanted to wait for confirmation from
> > > other users. So if James had some feedback, I'd appreciate it
> > > greatly.
>
> I'm trying to get this to work on windows,  I'm having a lot of units
> not found errors when I try to compile anything at all.. I'm not sure
> what I need here to get the examples to work.Here is a list of
> units I can't find when I try to compile with FPC 3.0.4RC1 on
> Windows:
>
> ezusb.pas(42,15) Fatal: Can't find unit Errors used by EZUSB
> I have no idea what Unit Errors is or what it might be for.

Thanks for pointing this out. This is a Unix unit, but it is obviously
not used in Ezusb. I've removed it now.

> libusb.pas(1350) Warning: Library c.dll not found, Linking may fail ! 
>■
> libusb.pas(1350) Warning: Library usb-1.0 not found, Linking may fail !
> I'm not really following where c.dll and usb1.0 are supposed to come from

It seems you didn't install the development stuff for libc and lib-usb?
At least in Linux, I always have to install these additionally (e.g.,
libusb-1.0-0-dev) to the "productive" libraries (e.g., libusb-1.0-0).

> usb.pas(31,22) Fatal: Can't find unit Baseunix used by USB

Same as above for Errors. However, this file is unused.

> mydevice.pas(27,20) Fatal: Can't find unit BaseUnix used by MyDevice
> I have no idea what BaseUnix does or if I can do something windows
> compatible instead somehow.

Same as above for Errors.

> Test1Library.pas:
> ║ (0) Error: Import library not found for c
> ║ (0) Error: Import library not found for usb-1.0

This seems to be again a problem because of the missing development
stuff for libc anc libusb.

> To be honest this is quite a bit over my head.  I'm trying to follow
> https://github.com/hansiglaser/pas-libusb/issues/4 but I'm just lost.

I would recommend, first to just compile the pristine pas-libusb
without any hints from that Github issue. Only if you get the same
errors, please try them and let me know.

As stated above, I've now removed all references to the units Errors
and Baseunix. Please "git pull" to the newest state on Github and
compile again. If you still face problems, please don't hesitate to ask
again.

Thanks
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-07-27 Thread Johann Glaser
Hi!

Am Samstag, den 27.07.2019, 14:27 +0200 schrieb Marc Santhoff:
> On Fri, 2019-07-26 at 22:37 +0200, Johann Glaser wrote:
> > Hi!
> >
> > Am Freitag, den 26.07.2019, 15:56 +0200 schrieb Marc Santhoff:
> > > On Thu, 2019-07-25 at 19:40 -0700, Brian wrote:
> > > > Try the libusb library Free Pascal interface .. but be aware of his
> > > > license
> > > > requirements. It works well.
> > > >
> > > > http://johann-glaser.blogspot.com/2012/07/libusb-for-pascal.html
> > >
> > > http://johann-glaser.blogspot.com/2012/09/libusb-10-for-pascal.html
> >
> > Thanks for referring to my translation!
> >
> > @Brian: I wasn't even aware of a license topic, but when checking back
> > now, the wrapper for the "old" libusb 0.1 states GPL in the README. I
> > think this was a bad idea.
> >
> > Thanks to Marc to point to the newer wrapper for libusb 1.0, which uses
> > the same license as libusb, and for all stuff from me the same as the
> > FPC units. Just use the branch "libusb-1.0".
> >
> > Anyhow, I would recommend to use libusb 1.0.
>
> I've seen "$ifdef Windows" in the Code, so it does support Windows without any
> change?
>
> If so, that would be James' solution.

I've never tested it on Windows myself, but I integrated some changes
provided by other users quite some time ago.

BTW: A few weeks ago I was contacted on Github regarding Windows
support. The user had some issues, but then he found a solution.

https://github.com/hansiglaser/pas-libusb/issues/4

Due to my lack of understanding of Windows, I've not yet taken over his
changes, because I wanted to wait for confirmation from other users. So
if James had some feedback, I'd appreciate it greatly.

Thanks
  Hansi


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


Re: [fpc-pascal] USB Human Interface Devices

2019-07-26 Thread Johann Glaser
Hi!

Am Freitag, den 26.07.2019, 15:56 +0200 schrieb Marc Santhoff:
> On Thu, 2019-07-25 at 19:40 -0700, Brian wrote:
> > Try the libusb library Free Pascal interface .. but be aware of his
> > license
> > requirements. It works well.
> >
> > http://johann-glaser.blogspot.com/2012/07/libusb-for-pascal.html
>
> http://johann-glaser.blogspot.com/2012/09/libusb-10-for-pascal.html

Thanks for referring to my translation!

@Brian: I wasn't even aware of a license topic, but when checking back
now, the wrapper for the "old" libusb 0.1 states GPL in the README. I
think this was a bad idea.

Thanks to Marc to point to the newer wrapper for libusb 1.0, which uses
the same license as libusb, and for all stuff from me the same as the
FPC units. Just use the branch "libusb-1.0".

Anyhow, I would recommend to use libusb 1.0.

If you need any support, feel free to contact me.

Bye
  Hansi


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


Re: [fpc-pascal] interactively draw an ellipse

2013-01-23 Thread Johann Glaser
Hi!

Please do your homework yourself.

Bye
  Hansi


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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-10-01 Thread Johann Glaser
Hi!

Am Sonntag, den 30.09.2012, 22:57 +0200 schrieb Christo:
> On Tue, 2012-09-25 at 22:32 +0200, Johann Glaser wrote:
> 
> > I only have access to Linux and don't know anything about Windows
> > development. So, I ask you (and anybody else) on the best and cleanest
> > way to make libusb.pas working in Linux and other OS.
> 
> 
> I have played around with your library to get it working on Windows XP.
> The most significant change I had to make was to change the libusbx
> import from static linking to dynamic loading.  I just couldn't get the
> static linking working in windows.
> 
> This created a slight problem with requiring the cthreads unit because
> the libusbx library is multithreaded.  I have added this to the libusb
> unit but it needs to be tested more because I don't understand how
> threading between C and fpc works.
> 
> Attached please find a diff file summarizing my changes based on your
> git copy from about a week ago.

Thanks for providing feedback and patches!

The major changes are that you use LoadLibrary instead of dynamic
linking at program start. Note that $LINKLIB is really doing dynamic
linking, not static linking. Therefore I don't see why procedural
variables should be needed here.

Secondly you test whether libusb_get_port_number() and
libusb_get_port_path() are available. I don't know how to handle this
properly. Why not just update to 1.0.12?

Third, at some points you added the unit CThreads. Looking at the
libusbx source code (and API documentation) reveals, that they don't use
threading, they only use the mutexes (pthread_mutex_*) and condition
variables (pthread_cond_*). I also don't know whether it is necessary to
install the Pascal Thread Manager therefore. I'll start a dedicated
thread for that.

Finally, you have added a different implementation of GetUSec which
works on Windows. Thanks for that!

For the clarification of the CThreads and the LoadLibrary stuff I've
created two separate branches libusb-1.0-cthreads and libusb-1.0-dynlib
with your changes (with slight capitalization changes, ...). I'll merge
these branches to libusb-1.0 as soon as these issues are clarified.

Thanks again
  Hansi


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


[fpc-pascal] CThreads for linked C library?

2012-10-01 Thread Johann Glaser
Hi!

libusb(x) links to libpthread:

$ ldd /lib/x86_64-linux-gnu/libusb-1.0.so.0
linux-vdso.so.1 => 
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
/lib64/ld-linux-x86-64.so.2

If I'm linking to libusb(x), the resulting executable also links to
libpthread.

Looking at the libusbx source code (and API documentation) reveals, that
they don't use threading, they only use the mutexes (pthread_mutex_*)
and condition variables (pthread_cond_*).

Is it necessary to have the unit "CThreads" in my Uses clause?

Thanks
  Hansi


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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-30 Thread Johann Glaser
Hi!

Am Mittwoch, den 26.09.2012, 08:56 +0200 schrieb Sven Barth:
> Am 25.09.2012 23:16, schrieb Henry Vermaak:
> > On 25 September 2012 20:57, Christo  wrote:
> >> Any ideas on how to define the calling convention in the import unit so
> >> that it is either stdcall or cdecl depending on the target OS?
> >
> > I've used a macro for this in the past.  E.g. :
> >
> > {$macro on}
> > {$ifdef windows}
> >{$define CCONV:=stdcall}
> > {$else}
> >{$define CCONV:=cdecl}
> > {$endif}
> >
> > Then use CCONV where you would specify the calling convention.
> 
> I would use "extdecl" instead of "CCONV" as the IDE and fpdoc has 
> special code to handle this (as they don't support macros).

Thank you for all your valuable suggestions!

I've now relicensed the units under the modified LGPL (as used by
Lazarus) and the examples as public domain.

Additionally I've included the above macro (using "extdecl").

https://github.com/hansiglaser/pas-libusb/tree/libusb-1.0

I also updated my other Pascal translations for the GNU Readline library
https://github.com/hansiglaser/pas-readline and the TCL interpreter
https://github.com/hansiglaser/pas-tcl . Note that the GNU Readline
library is pure GPL itself, therefore my stuff is GPL too.

Bye
  Hansi


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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-25 Thread Johann Glaser
Hi!

Am Dienstag, den 25.09.2012, 21:57 +0200 schrieb Christo:
> On Sun, 2012-09-23 at 23:26 +0200, Johann Glaser wrote:
> > Hi!
> > 
> > Some time ago somebody asked about USB support. I've now finished the
> > libusb 1.0 header translation and object-oriented wrapper.
> 
> Hi Hansi,
> 
> I see that the imported functions in libusb.pas are declared with the
> cdecl calling convention. According to the libusb header this is so for
> all operating systems except windows which is apparently compiled using
> the stdcall calling convention.
> 
> Any ideas on how to define the calling convention in the import unit so
> that it is either stdcall or cdecl depending on the target OS?

Thanks for pointing this out.

I only have access to Linux and don't know anything about Windows
development. So, I ask you (and anybody else) on the best and cleanest
way to make libusb.pas working in Linux and other OS.

Thanks
  Hansi


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


Re: [fpc-pascal] libusb header translation and OOP wrapper

2012-09-25 Thread Johann Glaser
Hi!

Am Dienstag, den 25.09.2012, 09:41 +0100 schrieb Graeme Geldenhuys:
> On 2012-09-24 14:39, Christo wrote:
> > I'm interested in testing your wrapper.  Unfortunately I cannot clone
> > the git link above, I get an error (fatal:
> > https://github.com/hansiglaser/pas-libusb/tree/libusb-1.0/info/refs not
> 
> 
> That was a web link, not the git url. If you followed that link with 
> your web browser, you would have  seen at the top  a ZIP button which 
> you can use to download the latest code of that branch in a zip archive. 
> There are also two git clone URL's. One uses the HTTP protocol, and the 
> other uses the faster GIT protocol.
> 
> 
>git clone https://github.com/hansiglaser/pas-libusb.git
> 
> or
> 
>git clone git://github.com/hansiglaser/pas-libusb.git
> 
> 
> then do...
> 
> cd pas-libusb
> git checkout libusb-1.0
> 
> 
> > Unfortunately the master branch appears to be 2 months old.
> 
> You simply forgot to switch to the 'libusb-1.0' branch.

Thanks Graeme and Henry for taking this "support request". :-)

BTW: Another user asked whether I'll release the files under a modified
LGPL Lazarus/FPC license. Yes, definitely. I hope I can push these
changes during the weekend.

Bye
  Hansi


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


[fpc-pascal] libusb header translation and OOP wrapper

2012-09-23 Thread Johann Glaser
Hi!

Some time ago somebody asked about USB support. I've now finished the
libusb 1.0 header translation and object-oriented wrapper.

Please find them at
  https://github.com/hansiglaser/pas-libusb/tree/libusb-1.0
including a few examples to demonstrate the usage.

I've updated http://wiki.lazarus.freepascal.org/Hardware_Access#libusb

I also tried to update my entry in
http://www.freepascal.org/contrib/contribs.html but got a
username/password problem (despite using the same as for the Wiki
above). 

Bye
  Hansi


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


Re: [fpc-pascal] C Enum vs. Integer

2012-09-13 Thread Johann Glaser
Hi!

Am Donnerstag, den 13.09.2012, 15:45 +0200 schrieb Jonas Maebe:
> Guillermo Martínez Jiménez wrote on Thu, 13 Sep 2012:
> 
> >> On 12 Sep 2012, at 19:11, Johann Glaser wrote:
> >>
> >>> Can I translate this 1:1, i.e., define an Enum in Pascal and just ignore
> >>> the compiler warnings about reused values?
> >>>
> >>> Or should I rather define all these types as Integer and define
> >>> constants for all values?
> >>
> >> It depends on whether you need arithmetic or not. If you do, use  
> >> integer constants, otherwise you can use an enum.
> >
> > Actually you cannot.  FPC optimizes enumerations in some cases (i.e.
> > in Delphi mode) but GCC uses 32bit for enumerations alwais.
> 
> The size of an enum in gcc depends on whether or not the -fshort-enums  
> command line option is used, and on the number of bits required to  
> represent its upper bound value.
> 
> > Anyway you can still use enums, but telling to FPC that you want to
> > set its size by directives $PACKENUM and $ENUMSIZE.
> 
> It's $PACKENUM *or* $ENUMSIZE (they affect the same compiler setting)
> 
> Anwyay, yes, that's also what I said the part of my original mail that  
> you cut away.

Thank you all for your valuable information!

I found that libusb doesn't use the enum types anywhere but use uint8_t
or int instead. So I use constants for everything now.

Only one enum is used (libusb_transfer_status) in two structs, so I
replaced it as it was an int.

@Stephano: Thanks for the link with contributed units. Actually, one of
the USB units is from me, but a bit outdated. When my libusb 1.0
translation (including an OOP wrapper) is done I'll update
http://wiki.freepascal.org/Hardware_Access#libusb and the contributed
units page again.

Thanks
  Hansi


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


Re: [fpc-pascal] FPC + fpGUI + Raspberry Pi = fantastic

2012-09-13 Thread Johann Glaser
Hi!

Am Donnerstag, den 13.09.2012, 19:55 +0100 schrieb Graeme Geldenhuys:
> On 13/09/12 17:35, Johann Glaser wrote:
> >
> > I also played with it, but only did a small "Hello World!" program. :-)
> 
> :-)
> 
> >http://johann-glaser.blogspot.co.at/2012/06/raspberry-pi.html
> 
> Thanks for the hint on your blog about making screenshots. I was just 
> about to Google on how to do that from inside 'Debian 6 for Pi'. The 
> normal 'xwd' or 'import' applications where not available (the latter 
> one pulls in too much dependencies). I'll try 'scrot' now.

Haha, yes, I was searching for that a while. :-)

Bye
  Hansi


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


Re: [fpc-pascal] FPC + fpGUI + Raspberry Pi = fantastic

2012-09-13 Thread Johann Glaser
Hi!

Am Donnerstag, den 13.09.2012, 16:34 +0100 schrieb Graeme Geldenhuys:
> Hi,
> 
> I received my Raspberry Pi today, and had a bit of a play. I'm using the 
> Debian 6 OS with my Pi. I downloaded the FPC+fpGUI ARM archive (only a 
> 3.5MB download), packaged by Paul Breneman.
> 
>http://www.turbocontrol.com/easyfpgui.htm
> 
> [Awesome work there, Paul. You can get much easier than than. Just 
> unpack and you are ready to work.]
> 
> It works fantastically well. I could compile all the fpGUI demos without 
> me having to do anything extra in fpGUI. How cool is that! :-)
> 
> All I had to do to get my projects to link successfully, was to install 
> a few missing packages, which were not included with the Debian 6 distro 
> for the Pi.
> 
>sudo apt-get update
>sudo apt-get install libX11-dev libXft-dev
> 
> I'll have to speak to somebody to see if they could include it as 
> standard - after all, the Pi is meant for developers to play with. If 
> anybody has contacts, please let me know.
> 
> I even compiled and ran the more complex fpGUI apps like the GUI Forms 
> Designer, DocView (help viewer), and Maximus (a sample fpGUI IDE). Even 
> FPTest (my Free Pascal Unit Testing project works).
> 
> We (our company) have some big plans for the Raspberry Pi, with a 
> potentially huge deployment. The first tests with this device is very 
> promising.
> 
> Kudos must also go to the FPC team, for supporting ARM so well!
> 
> Maybe with the Raspberry Pi and Free Pascal, we can get Object Pascal 
> back on the map, and in the hands of young developers. After all, Pascal 
> was initially designed as a teaching language - easy to learn, read and 
> write.

Congrulations!

I also played with it, but only did a small "Hello World!" program. :-)
  http://johann-glaser.blogspot.co.at/2012/06/raspberry-pi.html

Bye
  Hansi


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


[fpc-pascal] C Enum vs. Integer

2012-09-12 Thread Johann Glaser
Hi!

I'm working on a header translation for LibUSB and its fork libusbx.
They define several data types as C enums (for examples, see
http://libusbx.sourceforge.net/api-1.0/group__desc.html ).

They excessively use direct assignment of enum values, and even use one
value multiple times (e.g. LIBUSB_CLASS_PTP = 6, LIBUSB_CLASS_IMAGE =
6).

Can I translate this 1:1, i.e., define an Enum in Pascal and just ignore
the compiler warnings about reused values?

Or should I rather define all these types as Integer and define
constants for all values?

One more question: In some C structs and function parameters and return
values these enums are used too. How can I assure that the same memory
allocation is used?

Thanks
  Hansi


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


Re: [fpc-pascal] Readline substitute

2011-12-10 Thread Johann Glaser
Hi Krishna!

Am Samstag, den 10.12.2011, 12:13 +0530 schrieb Krishna:
> On Fri, Apr 29, 2011 at 10:18 PM, Johann Glaser  wrote:
> > Hi!
> >
> > I want to equip a program with a command line and therefore want a
> > powerful and user-friendly input prompt. Currently I use
> >  ReadLn(CmdLine);
> > which is not as user-friendly as desired. :-)
> >
> > The usual answer for this question is libreadline. I already worked with
> > it (in plain C) but before I do a header translation for FreePascal I
> > wanted to ask you for your opinion if there is a better alternative or
> > anybody already has a header translation or even programmer-friendly
> > wrapper for the history and auto-completion stuff.
> 
> linenoise[1] and editline[2] are alternatives. Don't know if there are
> pascal bindings to those.
> 
> [1]: https://github.com/antirez/linenoise
> [2]: http://www.thrysoee.dk/editline/

Thanks for the tips!

I've evaluated EditLine but it had drawbacks to GNU Readline. The
relatively young linenoise unfortunately doesn't properly support
completion.

As mentioned before, I've already settled with GNU readline and already
wrote header translations as well as an OOP wrapper. I hope both are
useful for somebody and also might be included in future versions of
FreePascal.

Thanks
  Hansi


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


Re: [fpc-pascal] Readline substitute

2011-12-10 Thread Johann Glaser
Hi Bernd!

Am Donnerstag, den 08.12.2011, 20:44 +0100 schrieb Bernd:
> 2011/5/1 Johann Glaser :
> 
> > If you find any improvements or comments don't hesitate to send me an
> > EMail.
> 
> I just used it. I only needed readline() and add_history(), these two
> functions are already enough to make a ReadLn() substitute that really
> works and It works like a charm! Thank you!
> 
> I think this code really deserves to be included in FPC.

Thanks for your feedback and support!

In the meantime I've added an OOP wrapper which greatly simplifies the
usage of the history and readline and helps to implement custom
completion.

Please find attached the OOP wrappers and a small example.

I've also used this OOP wrapper for a command line tool which integrates
the TCL OOP wrapper (mentioned in this list on 2011-05-05). The
completion correctly identifies whether it is asked for commands or
variables, and even works inside of the TCL equivalent of backticks. Due
to shortage of time it's still a bit messy, but will be released under
the terms of the GPL too.

Bye
  Hansi

(* Copyright (C) 1989-2011 Free Software Foundation, Inc.

   This file contains the FreePascal header translations for the
   GNU History Library (History), a set of routines for managing the
   text of previously typed lines.

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

   History 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 General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with History.  If not, see <http://www.gnu.org/licenses/>.
*)
Unit HistoryOOP;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, History;

Type

  { THistory }

  THistory = class
  private
FFilename  : String;
FAddDuplicates : Boolean;
  public
Constructor Create(AFilename:String);
Destructor  Destroy; override;

Procedure Read;
Procedure Write;
Procedure Print;
Function  List: PPHIST_ENTRY; inline;
Function  Length  : Integer; inline;
Function  GetLast : PHIST_ENTRY; inline;
Procedure Add(St:String);
property AddDuplicates : Boolean read FAddDuplicates write FAddDuplicates;
  End;

Implementation

// signelton static variable
Const HistoryInst : THistory = Nil;

{ THistory }

(**
 * Constructor
 *
 * AFilename: path to history file, if its empty, no history file is used, if
 *   it doesn't contain a '/', it is interpreted relative to the user's home
 *   directory.
 *)
Constructor THistory.Create(AFilename:String);
Begin
  { History is not thread-save }
  if assigned(HistoryInst) then
raise Exception.Create('You can only have a single THistory instance!');
  HistoryInst := Self; // set singleton static variable

  inherited Create;

  if AFilename <> '' then
Begin
  if Pos('/',AFilename) > 0 then
Begin
  // filename contains a '/' -> absolute path
  FFilename := AFilename;
End
  else
Begin
  // filename doesn't contain a '/' -> relative to home directory
  FFilename := GetEnvironmentVariable('HOME') + '/' + AFilename;
End;
End;
End;

Destructor THistory.Destroy;
Begin
  { clean up singleton static variable }
  if HistoryInst <> Self then
raise Exception.Create('Internal Error: HistoryInst <> Self');
  HistoryInst := Nil;

  Inherited Destroy;
End;

Procedure THistory.Read;
Begin
  if FFilename = '' then Exit;
  read_history(PChar(FFilename));
End;

Procedure THistory.Write;
Begin
  if FFilename = '' then Exit;
  write_history(PChar(FFilename));
End;

(**
 * Print the full history
 *)
Procedure THistory.Print;
Var H : PPHIST_ENTRY;
I : Integer;
W : Integer;
Begin
  // get the required width for the enumeration
  W := 0;
  I := Length;
  While I > 0 do
Begin
  Inc(W);
  I := I div 10;
End;

  // print the whole history list
  H := List;
  if H = Nil then Exit;
  I := 0;
  While H^[I] <> Nil do
Begin
  WriteLn(' ',(I+1):W,'  ',H^[I]^.Line);
  Inc(I);
End;
End;

Function THistory.List:PPHIST_ENTRY; inline;
Begin
  Result := history_list;
End;

Function THistory.Length:Integer; inline;
Begin
  Result := history_length;
End;

Function THistory.GetLast:PHIST_ENTRY;Inline;
Begin
  Result := history_get(Length);
End;

Procedure THistory.Add(St:String);
Var H : PHIST_ENTRY;
Begin
  if not FAddDuplicates then
Begin
  H := GetLast;
   

Re: [fpc-pascal] Readline substitute

2011-05-01 Thread Johann Glaser
Hi!

Am Freitag, den 29.04.2011, 18:48 +0200 schrieb Johann Glaser:
> Hi!
> 
> I want to equip a program with a command line and therefore want a
> powerful and user-friendly input prompt. Currently I use
>   ReadLn(CmdLine);
> which is not as user-friendly as desired. :-)
> 
> The usual answer for this question is libreadline. I already worked with
> it (in plain C) but before I do a header translation for FreePascal I
> wanted to ask you for your opinion if there is a better alternative or
> anybody already has a header translation or even programmer-friendly
> wrapper for the history and auto-completion stuff.

Ok, I was too impatient and did the header translation now. :-) Please
find attached the units Readline and History as well as five example
programs. This is compatible to the most current version 6.2
  http://tiswww.case.edu/php/chet/readline/rltop.html

Everything is GPL as the GNU Readline Library is itself. I'd be happy if
these files can be included in future FreePascal releases.

If you find any improvements or comments don't hesitate to send me an
EMail.

Thanks
  Hansi



readline-pas.tar.gz
Description: application/compressed-tar
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Readline substitute

2011-04-29 Thread Johann Glaser
Hi!

I want to equip a program with a command line and therefore want a
powerful and user-friendly input prompt. Currently I use
  ReadLn(CmdLine);
which is not as user-friendly as desired. :-)

The usual answer for this question is libreadline. I already worked with
it (in plain C) but before I do a header translation for FreePascal I
wanted to ask you for your opinion if there is a better alternative or
anybody already has a header translation or even programmer-friendly
wrapper for the history and auto-completion stuff.

Thanks
  Hansi


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


Re: [fpc-pascal] SNAPI Driver and USB HID

2010-09-07 Thread Johann Glaser
Hi!

Am Dienstag, den 07.09.2010, 01:01 +0200 schrieb Luca Olivetti:
> Al 06/09/10 22:28, En/na Johann Glaser ha escrit:
> 
> > Unfortunately, /dev/ttyUSB0 is not standardized but requires different
> > drivers for every chip (e.g. cp2101, ft232, ...). For the MS4407 scanner
> > I didn't yet find a serial driver. So, unfortunately, the RS232
> > emulation does not work too. :-(
> 
> That's worrying, since I'm going to have to use a similar symbol scanner 
> in the near future.
> Did you actually try to plug it in when configured in com port emulation?
> If so, what did you see in dmesg, /var/log/syslog?

Just that it is a HID device. Looking at lsusb -d showed a much smaller
amount of endpoints like with the SNAPI interface. But the kernel did
not load any serial driver.

Probably the scanner does emulate an UART chip which resembles one of
those the kernel has drivers (e.g. cp2101 or so), but playing around is
tedious.

OTOH the Sub-D-9 connector also provides real RS232 signals (with TTL
level) besides the USB signals. But this is not an option for me.

Bye
  Hansi


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


Re: [fpc-pascal] SNAPI Driver and USB HID

2010-09-06 Thread Johann Glaser
Hi Henry!

Am Montag, den 06.09.2010, 22:44 +0100 schrieb Henry Vermaak:
> On 6 September 2010 18:07, Johann Glaser  wrote:
> > Hi!
> >
> > I've bought a barcode scanner (Symbol MS4407) with an USB interface and
> > want to use that with Linux. Unfortunately Motorola (who bought Symbol a
> > few years ago) do not provide Linux drivers and also do not provide USB
> > protocol documentation, even after some pushy support questions.
> >
> > For Windows they provide a SNAPI DLL plus a .h file. Does anybody know a
> > Linux version of the SNAPI driver, preferably written in FreePascal?
> >
> > As I'm not very confident that such a driver does exist, I've also
> > evaluated the USB descriptors and such stuff. The scanner offers an USB
> > HID class interface. Some search in this mailing list archives reveals,
> > that Jonas pointed to a freelance job to provide some USB HID reader on
> > 2009-07-21 and 2009-09-16. Are there any (freely) available results from
> > these jobs? Does anybody else have information on how to use the
> > Linux /dev/hid... stuff with Pascal? Or how to work with the USB HID
> > descriptor stuff?
> 
> I know about libhid, maybe that helps?

Thanks for the hint. I must have overlooked this in my previous
searches.

Thanks!
  Hansi


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


Re: [fpc-pascal] SNAPI Driver and USB HID

2010-09-06 Thread Johann Glaser
Hi Luca!

> > As I'm not very confident that such a driver does exist, I've also
> > evaluated the USB descriptors and such stuff. The scanner offers an USB
> > HID class interface.
> 
>  From the manual I see that it also offers com port emulation. In that 
> case it should provide a serial interface (e.g. /dev/ttyUSB0) that you 
> can simply read with synaser or another serial port library.
> I don't know (yet) how the usb model works, but the plain serial one can 
> be configured to send the barcode terminated with cr+lf, and that's easy 
> to read.

Thank you for looking this up. I also investigated this, but
unfortunately there is no "driver" for the /dev/ttyUSB0. A year ago I
used a DataLogic scanner which uses the /dev/ttyACM0 interface, which is
a standardized interface defined by the USB organization.
Unfortunately, /dev/ttyUSB0 is not standardized but requires different
drivers for every chip (e.g. cp2101, ft232, ...). For the MS4407 scanner
I didn't yet find a serial driver. So, unfortunately, the RS232
emulation does not work too. :-(

Thanks
  Hansi


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


[fpc-pascal] SNAPI Driver and USB HID

2010-09-06 Thread Johann Glaser
Hi!

I've bought a barcode scanner (Symbol MS4407) with an USB interface and
want to use that with Linux. Unfortunately Motorola (who bought Symbol a
few years ago) do not provide Linux drivers and also do not provide USB
protocol documentation, even after some pushy support questions.

For Windows they provide a SNAPI DLL plus a .h file. Does anybody know a
Linux version of the SNAPI driver, preferably written in FreePascal?

As I'm not very confident that such a driver does exist, I've also
evaluated the USB descriptors and such stuff. The scanner offers an USB
HID class interface. Some search in this mailing list archives reveals,
that Jonas pointed to a freelance job to provide some USB HID reader on
2009-07-21 and 2009-09-16. Are there any (freely) available results from
these jobs? Does anybody else have information on how to use the
Linux /dev/hid... stuff with Pascal? Or how to work with the USB HID
descriptor stuff?

Thanks
  Hansi


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


Re: [fpc-pascal] PC/SC

2010-09-01 Thread Johann Glaser
Hi!

Am Mittwoch, den 01.09.2010, 22:55 +0200 schrieb Michael Van Canneyt:
> 
> On Wed, 1 Sep 2010, Johann Glaser wrote:
> 
> > Hi!
> >
> > Am Mittwoch, den 01.09.2010, 16:27 -0400 schrieb DaWorm:
> >> Project Jedi has translations for Delphi.  I don't know how easily
> >> they could be used for Linux and the PC/SC Lite used there, but it
> >> could be a helpful start.
> >
> > Google pointed me to a Delphi component at
> > http://www.nobbi.com/download/pcsccomp.zip which looks very fine. It
> > includes (modified) versions of some JEDI header translations plus a
> > fine OOP wrapper for PC/SC. But everything is for Windows and I'm
> > unfamiliar with it and with components. So I thought I'd rather ask here
> > for some help.
> 
> I am using this component (heavily improved) but it's geared towards
> the microsoft API. The Linux API (openSC) has not been translated as 
> far as I know.

I'm using PCSC-Lite (http://pcsclite.alioth.debian.org/) which is AFAIK
a Linux version of the M§ API. At least its API
http://pcsclite.alioth.debian.org/api/group__API.html looks quite
similar to what I've seen in this component.

Bye
  Hansi


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


Re: [fpc-pascal] PC/SC

2010-09-01 Thread Johann Glaser
Hi!

Am Mittwoch, den 01.09.2010, 16:27 -0400 schrieb DaWorm:
> Project Jedi has translations for Delphi.  I don't know how easily
> they could be used for Linux and the PC/SC Lite used there, but it
> could be a helpful start.

Google pointed me to a Delphi component at
http://www.nobbi.com/download/pcsccomp.zip which looks very fine. It
includes (modified) versions of some JEDI header translations plus a
fine OOP wrapper for PC/SC. But everything is for Windows and I'm
unfamiliar with it and with components. So I thought I'd rather ask here
for some help.

> If you don't mind me asking, which Mifare reader supports PC/SC?  I
> use both chipcard and Mifare readers, but hadn't seen a PC/SC Mifare
> reader before.

Its an SCM SCL010 reader (really cheap, small and simple, exactly what I
was looking for). They offer a proprietary pcsclite driver at their
homepage, which simply installs a .so file (and a metadata file) to the
driver module directory /usr/lib/pcsc/drivers/. Interestingly the
Info.plist file says the driver was LGPL, but their homepage says its
proprietary. No source is available. :-(

I've already read the unique serial number from MiFare cards using the
"gscriptor" tool in the pcsc-tools package. So, the driver works, PC/SC
works, I only need an Pascal interface to PC/SC to start playing. :-)

Thanks
  Hansi


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


Re: [fpc-pascal] PC/SC

2010-09-01 Thread Johann Glaser
Hi!

> > For a project with wireless chip cards (MiFare) I'm using a reader which
> > is accessed via the PC/SC interface. Did anybody write a Pascal unit to
> > translate the C header files?
> 
> Is this for linux or windows ?

I'm working on Linux.

Thanks
  Hansi


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


[fpc-pascal] PC/SC

2010-09-01 Thread Johann Glaser
Hi!

For a project with wireless chip cards (MiFare) I'm using a reader which
is accessed via the PC/SC interface. Did anybody write a Pascal unit to
translate the C header files?

Thanks
  Hansi


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


Re: [fpc-pascal] [ANN] BeepFp v1.1 released

2010-04-21 Thread Johann Glaser
Hi!

Am Dienstag, den 20.04.2010, 14:36 -0300 schrieb Jorge Aldo G. de F.
Junior:
> hahahahhahah
> 
> BEEP has nothing to do with beeping from the application :P

:-D Yes, it was a joke. :-p Sorry for the confusion, I should have added
"SCNR" to my mail. :-)

Bye
  Hansi


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


Re: [fpc-pascal] [ANN] BeepFp v1.1 released

2010-04-19 Thread Johann Glaser
Hi!

Am Montag, den 19.04.2010, 08:53 +0200 schrieb Wimpie Nortje:
> Release note:
> -
> BeepFp 1.1 was released on April 18, 2010.
> 
> BeepFp is a Free Pascal component to provide BEEP services in the object
> pascal language. It is written as a binding on top of Vortex library.

Isn't that as easy as just using
  Write(^G);
?

Bye
  Hansi


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


Re: [fpc-pascal] some new features to delphi prisem

2010-02-23 Thread Johann Glaser
Hi!

Am Samstag, den 20.02.2010, 19:01 +0100 schrieb Jürgen Hestermann:
> 
> > y := case Other of
> >  bla : 'hello';
> >  foo : 'bye';
> >  baz : 'adius';
> >end;
> 
> What do you gain with this?
> Doesn't look much different to
> 
> case Other of
>bla : y := 'hello';
>foo : y := 'bye';
>baz : y := 'adius';
>end;

You are looking at the wrong example! Clearly, for variable assignment
you don't gain anything. But for a function argument you do!

  WriteLn('The value is ',(if X then 'true' else 'false'),
  ' at the moment.');

and

  MakeBackup(FileName,ChangeExtension(FileName,
case BackupExtension of
  exBak   : '.bak';
  exBkp   : '.bkp';
  exTilde : '~';
else '.bak'
End));

Bye
  Hansi


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


Re: [fpc-pascal] Linux USB programming using FPC

2009-06-15 Thread Johann Glaser
Hi!

Am Montag, den 15.06.2009, 16:37 +0100 schrieb Henry Vermaak:
> 2009/6/15 Johann Glaser :
> >
> > @FPC team: Are you interested in including the libusb header
> > translations (and possibly the other stuff) to FPC rtl?
> 
> I assume you mean the fpc packages.  Just for info:
> 
> libusb 0.1* is not developed any more, since libusb 1.0 was released
> end of last year.  libusb 1.0 hasn't made it into debian stable, yet,
> from what I can see, and with 91 pakcages depending on libusb 0.1, I
> guess it'll be around for a while still.  There is a compatibility lib
> called libusb-compat that allows programs to talk to libusb 1.0 with
> the 0.1 api, though.  libusb 1.0 supports linux and darwin at the
> moment.

Thanks for clarifying this, I was not aware of this rough transition.

> So when adding a libusb 0.1 package, the other (newer) releases should
> probably be added, too.

Good idea, yes. I can do the translations in the summer (July) if
requested. I'll also further improve and generalize the USB utilities
stuff. All suggestions are welcome!

Thanks
  Hansi


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


Re: [fpc-pascal] Linux USB programming using FPC

2009-06-15 Thread Johann Glaser
Hi!

Am Montag, den 15.06.2009, 09:44 +0200 schrieb fpcl...@silvermono.co.za:
> Hi guys,
> 
> I'm interested in exploring the USB interface from within Linux using FPC.
> I have looked at libusb and am aware of the functionality which it exposes. 
> 
> I would appreciate it if someone with USB programming experience could help 
> by 
> pointing me to a website or documentation that reveals a bit more than just 
> iterating through connected devices on a USB bus. A code snippet or two would 
> be most helpful. 
> 
> While I am aware that specific device drivers are required in order to access 
> specific USB devices, code samples demonstrating reading and writing to and 
> from a file system on USB stick would be most welcome.

As Henry already pointed out, file system (and block device) access of
USB mass storage devices is already there in the Linux kernel.

For other kinds of devices, especially where the Linux kernel has no
built in drivers, you can use libusb.

Some time ago I did header translations for it. I'll attach it
(libusb.pas) plus some utilities and a class wrapper (usbutil.pas),
firmware download to Cypress EZ-USB AN2131 (and related) chips
(ezusb.pas), intel hex file reader (intelhex.pas), and some generic
utilities (utils.pas) used by the other units. As an example of a device
driver for a simple device I built, I'll attach accudraindev.pas.
Unfortunately it's rather uncommented, sorry.

@FPC team: Are you interested in including the libusb header
translations (and possibly the other stuff) to FPC rtl?

Bye
  Hansi



usb.tar.gz
Description: application/compressed-tar
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Generating code form xmi files

2009-04-06 Thread Johann Glaser
Hi!

Am Sonntag, den 05.04.2009, 21:47 -0700 schrieb leledumbo:
> Err... how to use this codegen thing? Do I need to run it over Dia generated
> diagrams or what? Sorry, I don't understand Python.

Replace the installed codegen.py file by the one at the mentioned URL
below. Then delete codegen.pyc (its "compiled"). You can run
"py_compilefiles codegen.py" to create a new compiled version.

If you restart Dia with the new file, in the File->Export menu you get
an additional export type "Pascal".

Bye
  Hansi


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


Re: [fpc-pascal] Generating code form xmi files

2009-04-05 Thread Johann Glaser
Hi!

Am Sonntag, den 05.04.2009, 11:24 -0300 schrieb Osvaldo Filho:
> http://www.opensubscriber.com/message/dia-l...@gnome.org/11515637.html

The current version is available at
  http://k7103.svn.sourceforge.net/viewvc/k7103/branch/ng/dia-codegen/

Bye
  Hansi


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


Re: [fpc-pascal] Acces IO-ports in Linux with FPC 2.2.0

2009-03-05 Thread Johann Glaser
Hi!

> I am developing a free pascal software in Linux, which uses the
> parallel digital input/output card (with intel 8255) in an industrial PC.
> I was able to compile and run without problems with FP 2.0.4.
> 
> Now, that the oldlinux unit is removed in the latest FPC,
> I cannot compile the program any more.
> The error messages are:
> - identifier not found "fdOpen"
> - identifier not found "fdWrite"
> - identifier not found "fdRead"

It seems you have a driver for this card and want to talk to the driver
via a Linux device (in /dev/). My first thought was you wanted to access
x86 IO ports (using IN and OUT instructions).

Simply use the online help to find the desired functions, e.g.
  http://community.freepascal.org:1/docs-html/rtl/baseunix/fpopen
This also lists the constants used for the access mode.

Bye
  Hansi


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


Re: [fpc-pascal] Verify if string is a valid number

2008-11-23 Thread Johann Glaser
Hi!

Am Sonntag, den 23.11.2008, 14:18 -0200 schrieb Felipe Monteiro de
Carvalho:
> Hello,
> 
> I would like to verify if a string is a valid number, as in StrToInt
> will work when applied to it. The obvious way is making a try
> statement:
> 
>   try
> StrToInt(TokenStr);
> AdicionarToken(tNumeroLiteral, TokenStr);
>   except
> AdicionarToken(tId, TokenStr);
>   end;
> 
> but I don't like this solution, because a lot of exceptions will be
> caused by normal execution of my program, which will disturb debugging
> it ...

Always avoid exceptions if possible, since they are very costly in terms
CPU time. Do your error handling with exceptions, but not routine tests.
This would be misuse of exceptions.

For your problem just use the original Pascal procedure
  Val(St:String;Var Value,Position:Integer)
which simply returns the position of an illegal character or 0 if the
string was a legal number.

Bye
  Hansi


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


Re: [fpc-pascal] SSocket: TSocketServer.StopAccepting

2008-09-06 Thread Johann Glaser
Hi!

> I am using Synapse for all my socket work, so this might be a bit 
> different for you. But for a blocking listener in a thread (waiting at 
> an Accept), I call AbortSocket. It immediately stops all work on the 
> socket and lets you do the things you need to do. I'm sure there's a 
> similar "Abort" function in the package you are using.

Thanks for the hint. I looked at Synapse but it was too much of an
overkill for me. I managed to get ssockets working by setting
MaxConnections to 1, doing a dummy-connect to abort listening (which
still has a problem if the listening didn't start) and a little patch to
ssockets (http://mantis.freepascal.org/view.php?id=12040).

Bye
  Hansi


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


[fpc-pascal] SSocket: TSocketServer.StopAccepting

2008-08-30 Thread Johann Glaser
Hi!

I'm using the SSocket unit with TSocketServer (and TInetServer) for
TCP/IP communication in a multi-threaded application. To listen (and
accept) connections from a client the method StartAccepting is called.
This is a blocking function.

To quit the server I call StopAccepting. The implementation just sets a
variable which is checked by StartAccepting.

There are two problems:
1) If using the TSocketStream in blocking mode, the accept() call used
by StartAccepting does not return at all, so StopAccepting is somewhat
useless here.
2) In non-blocking mode the internal variable is checked periodically,
but not really often, so race conditions with Destroy can happen.

In both cases, when I want to quit my program, there is no safe way to
stop accepting at the socket, except from OnConnect (as shown e.g.
in /packages/fcl-base/examples/isocksvr.pp).

So there are some ideas to solve this.

First: Send a SIGTERM to this thread, accept() will return with EINTR,
which should then be checked for in TInetServer.Accept,
TUnixServer.Accept, ... and generate a special exception which is then
again checked for in TSocketServer.StartAccepting which simply exits the
loop.

Second: Do a dummy connect to myself and check for FAccepting directly
after Accept returns and then leave the loop. I prefer this one. OTOH
this depends on knowing one's own address and allowing this connection
by the firewall rules.

In any case, I suggest that StopAccepting really waits and only returns
after StartAccepting has finished. This also must be used in Destroy.
Here we have to take care for the case if StopAccepting is called from
OnConnect.

Did I miss something? Do you have other ideas? If you agree with my
idea, I'll implement the changes and send a patch for that.

Bye
  Hansi


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


Re: [fpc-pascal] Understanding the .bin format

2008-08-13 Thread Johann Glaser
Hi!

> Does anyone have the specification for the .bin (binary) file type?

No. Because there is no such ".bin format".

File name extensions (e.g. ".bin") are NOT the file format[1] (e.g. JPEG
image)!

Unfortunately Windows strives to let people assume that, but it is
wrong. The extension is an arbitrary part of the file name. Not more,
not less. Foolishly Windows uses this as specification of the file
format (e.g. when associating programs to start when double-clicking a
file in the Explorer). It even tries to assure this by warning you when
you modify the extension. All this lets user assume that the extension
says something about the content. Again, this assumption is generally
wrong (despite often it is by accident right).

So, if you have a file with a certain extension, you can not rely on its
format. This is especially true for files with such generic extensions
like ".bin" (short for "binary") or ".dat" (short for "data"). This
extensions are used by hundreds of different programs, each with a
totally different formats.

Bye
  Hansi

[1] File Format: specifies the meaning of the individual bits and bytes
at certain locations in a file


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


Re: [fpc-pascal] Access inherited^2

2008-08-10 Thread Johann Glaser
Hi!

Am Sonntag, den 10.08.2008, 10:01 +0200 schrieb Vincent Snijders:
> Johann Glaser schreef:
> > Hi!
> > 
> > How can I access an inherited inherited method which was overloaded?
> 
> Try the following, mark the constructors as overloaded:
> > 
> > == Example: ==
> > 
> > {$mode objfpc}{$H+}
> > Program TestInherited;
> > Uses Classes, SysUtils;
> > 
> > Type
> >   TFirst = class
>  Constructor Create(A,B,C:Integer); overload;
> >   End;
> >   TSecond = class(TFirst)
>  Constructor Create(A,B:Integer); overload;
> >   End;
> >   TThird = class(TSecond)
>   Constructor Create(A,B:Integer); overload;
> >   End;

Thanks, that really helped now. While Zaher Dirkey's hint (Mon, 4 Aug
2008 15:24:03 +0300) also helped and did it's job, it had one drawback:
If TFirst.Create raised an exception, this could not by caught by
TThird.Create. Even worse, it "converted" to an "Access violation"
exception.

I debugged this issue and found that it happend at a "call 0x30(%ecx)"
instruction in TThird.Create. ECX pointed to a memory structure where
address 0x30 was $. This seems very likely to be a problem with
internals of FPC's handling of constructors and exceptions.

Using "overload" now works like a charm. Michael, could you please add
this to the documentation?

Thanks
  Hansi


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


Re: [fpc-pascal] Access inherited^2

2008-08-04 Thread Johann Glaser
Hi!

Am Montag, den 04.08.2008, 08:23 -0300 schrieb Joao Morais:
> Johann Glaser wrote:
> > How can I access an inherited inherited method which was overloaded?
> 
> You can't, one of them will need to have a different name.

Thanks.

Why is a method hidden, just because it has the same name? Isn't it a
totally different method, because it has different parameters? Then it
should be visible. Or did I miss something?

Bye
  Hansi


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


[fpc-pascal] Access inherited^2

2008-08-03 Thread Johann Glaser
Hi!

How can I access an inherited inherited method which was overloaded?

== Example: ==

{$mode objfpc}{$H+}
Program TestInherited;
Uses Classes, SysUtils;

Type
  TFirst = class
Constructor Create(A,B,C:Integer);
  End;
  TSecond = class(TFirst)
Constructor Create(A,B:Integer);
  End;
  TThird = class(TSecond)
Constructor Create(A,B:Integer);
  End;

Constructor TFirst.Create(A, B, C: Integer);
Begin
  { ... }
End;

Constructor TSecond.Create(A, B: Integer);
Begin
  inherited Create(A,B,0);
End;

Constructor TThird.Create(A, B: Integer);
Begin
  inherited Create(A,B,0);   { <-- Error: Wrong number of parameters specified 
for call to "Create" }
End;

Begin

End.

===

The compiler complains in TThird.Create that the call to the inherited
method doesn't work. Removing the word "inherited" doesn't help.

What happened to the method with 3 parameters? Why is there an error
message? How can I access it?

Thanks
  Hansi


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


Re: [fpc-pascal] Printing of Pointer Type

2008-07-17 Thread Johann Glaser
Hi!

Am Donnerstag, den 17.07.2008, 21:52 +0200 schrieb Mattias Gaertner:
> On Thu, 17 Jul 2008 10:45:22 +0200
> "Vinzent Höfler" <[EMAIL PROTECTED]> wrote:
> 
> > leledumbo <[EMAIL PROTECTED]>
> > > 
> > > Jonas Maebe-2 wrote:
> > > > 
> > > > Because there are easy ways around it (as you mention) and the
> > > > work to implement and maintain this would probably outweigh the
> > > > usefulness.
> > > > 
> > > Yes, it's easy but uncomfortable and needs more typing.
> > 
> > Well, sure, but printing pointer values in most cases is a pure
> > debugging aid and nothing really useful.
> 
> Well. Since the biggest time of programming is spent on debugging I
> guess, there is more need for a PtrToStr than for FloatToStr.

I suggest to extend Write and WriteLn, that for Pointer typed parameters
those are printed in hex, e.g.

Var Edit : TEdit;
Begin
  Edit := TEdit.Create;
  WriteLn('Edit = ',Pointer(Edit));
End

then prints to the screen

  Edit = $B0283958

Would be very handy for debugging, similar like C++'s 
  cout << "Edit = " << (void*)Edit << endl;
(okok, streams are ugly syntax at least, but the overloaded operator for
untyped (void) pointers comes in handy instead of FreePascal's
IntToHex(PtrUInt(Edit),8)

Bye
  Hansi


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


Re: [fpc-pascal] Easiest way to get Lazarus on Linux

2008-06-22 Thread Johann Glaser
Hi!

Am Sonntag, den 22.06.2008, 10:12 +0200 schrieb Rainer Stratmann:
> Exists there a Debian DC/DVD with Lazarus on it?
> If yes where can I download it.

Lazarus is in the Debian repository [1], so you only have to add a
Debian mirror to your sources.list and install the Lazarus packages.

Bye
  Hansi

[1] http://packages.debian.org/sid/lazarus


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


Re: [fpc-pascal] Pascal postscript reading library

2008-04-24 Thread Johann Glaser
Hi!

> I am a little impressed that everyone says postscript is so complex,
> so I'm reevaluating which path to go, but I do have a competent
> software developer available to whom send the task, so the amount of
> work isn't that much a problem =P (as long as it is doable by 1 person
> in a couple of months)

Please note that PostScript is actually a full features programming
language, which (just "accidentially") has some commands suitable to
draw on a page. So, in PostScript there are infinite different ways to
describe an identical page. Compare to a "descriptive" printer language
or drawing/image format (like HPGL, PDF, DXF, SVG, PCL, JPG, ...) where
only the order but not the way an element is expressed can be different.

AFAIK in PostScript you can express a lot of difficult stuff like
clipping paths (even a font can be a clipping path for your drawing).
So, while a PS interpreter is relatively easy to develop (for a computer
scientist), the printing engine (controlled by the PostScript program)
is not trivial at all.

I recommend to search either for
 - a descriptive printer language / page description language
 - a postscript interpreter which offers the page in some descriptive
   terms (e.g. a list of elements)

Bye
  Hansi

PS: Since you are developing a Windows printer driver you could simply
convert the GDI commands to the CNC commands without the PostScript
intermediate step. But I dislike this option because this would give a
fully platform-dependent driver.


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


Re: [fpc-pascal] Hmm 64 bit instructions for visual studio 2008 slower than doubles too ?

2008-03-11 Thread Johann Glaser
ever head about indentation?


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


Re: [fpc-pascal] Question on programming serial communication.

2008-02-25 Thread Johann Glaser
Hi!

> 3. I will prefer to simply open a /dev/ttyXX from my central software and
>talk to my controllers then. If this is interrupt driven or not, I do
>not really (want to) care about.
>I expect that an Operating System like Linux will be able to give me
>that functionality and does all this low level stuff by itself?
> 
>I only want to use sme kind of API, Class, Object or set of procedures
>which allows me similar things as were possible with the FOSSIL 
>driver:
>- Buffered I/O
>- Flow Control as I need (RTS/CTS, XON/XOFF, Both, None)
>- Direct Control of control lines like DTR, ...
>- Possibilities for monitoring fill level of buffers, to force
>  them to be erased (made empty), ...

In Linux you simply open() the /dev/ttySxx device and then read() and
write() to it. This is for data, for other stuff (e.g. flow
control, ...) can be done via ioctl() (please excuse the C syntax). But
as Horacio already said you probably go better with a wrapper, e.g.
Synaser or TSerial (but I didn't use either).

Your second problem could be to find suitable Linux drivers for your
special multiport-RS232 hardware. But I assume you already got it
working.

Bye
  Hansi


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


Re: [fpc-pascal] Maybe a new fpc book :)

2008-01-02 Thread Johann Glaser
Hi!

> > 1. What OS is most-used for Free Pascal? Windows? Linux?
> 
> If I remember the download statistics correctly:
> Windows comes first and then Linux.

I want to note that mostly all Windows users download FreePascal and
Lazarus by their own from the original download servers. OTOH many Linux
users get FreePascal via their distribution. At least Debian provides
packages, but I assume some other distributions too.

So it all is about the "invisible" Linux downloaders. Do they really
exist? Or do they update so regularly that they don't want to rely on
their distribution?

Bye
  Hansi


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


Re: [fpc-pascal] function alias

2007-10-06 Thread Johann Glaser
Hi!

> procedure OriginalProc(..).. {$IFDEF USEINLINE_ALIAS}inline;{$ENDIF}
> begin
> end;
> ...
> 
> procedure AliasProc(...);
> begin
>   {$DEFINE USEINLINE_ALIAS}
>   OriginalProc(...);
>   {$UNDEF USEINLINE_ALIAS}
> end;

Are you sure this works? AFAIK the "preprocessor" doesn't follow
function calls but simply reads the .pas file from its first line to the
end.

Another problem is that the OP wanted to alias external functions, where
he can't define them as inline.

But he can reverse your approach:

Procedure NewName(...); inline;
Begin
  OriginalProc(...);
End;

Bye
  Hansi


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


Re: [fpc-pascal] Freepascal 2.2.0 released

2007-09-11 Thread Johann Glaser
Hi!

> > procedure abc(const x:array of byte);
> > 
> > begin
> > end;
> > 
> > var b:array[0..15] of byte;
> > 
> > begin
> >   abc(b[0..9]);
> > end;
> 
> I see, pretty neat for handling array row-wise or the like, thanks.

Is it also possible to run
  abc(b[2..9]);
i.e. using a start-index different from 0?

Bye
  Hansi


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


[fpc-pascal] XTerm window resize [was: Re: hmm, freevision]

2007-08-30 Thread Johann Glaser
Hi!

> Basically just that, if you change the size the console window fp is in, 
> the application sizes itself to fit the window.  it's a skill I'd like 
> to duplicate, as the app will be a console app with an interface, and 
> the fvision demo didn't do the neat trick.

Probably this is of interrest for you: The terminal sends a SIGWINCH to
the running process when it is resized. The process then requests its
current size by an ioctl() TIOCGWINSZ to the stdout handle (0).

You can test this in a simple shell window. Start two xterms (or which
terminal you like, now called "A" and "B") and then do an "strace -p
" in terminal A of the shell in terminal B (get its PID using "echo
$$"). Then resize terminal B with the mouse. I get the following output
of strace every time the size changes:

read(0, 0xbffe5d3f, 1)  = ? ERESTARTSYS (To be restarted)
--- SIGWINCH (Window changed) @ 0 (0) ---
ioctl(0, TIOCGWINSZ, {ws_row=24, ws_col=80, ws_xpixel=480, ws_ypixel=312}) = 0
write(2, "\r\33[K\33]0;[EMAIL PROTECTED]:~\7\33[44;1;31m"..., 97) = 97
sigreturn() = ? (mask now [])
read(0, 

Bye
  Hansi


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


Re: [fpc-pascal] Alternative to Makefiles for fpGUI

2007-08-10 Thread Johann Glaser
Hi!

Am Freitag, den 10.08.2007, 15:24 +0200 schrieb Michael Van Canneyt:
> 
> On Fri, 10 Aug 2007, Graeme Geldenhuys wrote:
> 
> > On 10/08/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote:
> > >
> > > It's super configurable.
> > >
> > > ./fpmake --help
> > >
> > > will give you all options, in good unix tradition :-)
> > 
> > And here I thought I would trip you up with my fpGUI example. :)
> 
> Well, it must be able to compile RTL and FCL, and those are
> quite tricky too...

Is there any documentation (like the things you've written in this
thread) in the Wiki? If not, I'd like to copy-paste (and clean up) your
discussion. Please point me to a place where the information best fits.

Bye
   Hansi


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


Re: [fpc-pascal] Wiki Syntax Highlight

2007-06-11 Thread Johann Glaser
Hi!

Am Sonntag, den 10.06.2007, 15:35 +0200 schrieb Vincent Snijders:
> Johann Glaser schreef:
> > Hi!
> > 
> >> I installed GesHi and one of the extensions: see 
> >> http://wiki.lazarus.freepascal.org/Executing_External_Programs for the 
> >> results.
> > 
> > Thanks a lot! I've beautified the Web Service Toolkit page now.
> > 
> > Unfortunately the documentation about the Wiki itself is quite sparse
> 
> Indeed feel free to fill the gap.
> 
> > (i.e. about the syntax highlighting its just the one page you've
> > mentioned as an example). I've added an item to
> > http://wiki.freepascal.org/Site_Feedback about writing a wiki doc
> > overview page. Please consider creating such a page, this could also
> > take over the paragraph with the links to wiki tutorials from the main
> > page. Please also add all specialities about the FreePascal Wiki like
> > configuration settings enabling/disabling some syntax elements, ...
> >
> 
> Can you do that? I am not much of a writer and you know as much of it as 
> I do.

Ok, done. For all who want to use the fresh syntax highlighter, please
visit http://wiki.freepascal.org/wiki_documentation and read how it is
used.

Bye
  Hansi


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


Re: [fpc-pascal] Wiki Syntax Highlight

2007-06-10 Thread Johann Glaser
Hi!

> I installed GesHi and one of the extensions: see 
> http://wiki.lazarus.freepascal.org/Executing_External_Programs for the 
> results.

Thanks a lot! I've beautified the Web Service Toolkit page now.

Unfortunately the documentation about the Wiki itself is quite sparse
(i.e. about the syntax highlighting its just the one page you've
mentioned as an example). I've added an item to
http://wiki.freepascal.org/Site_Feedback about writing a wiki doc
overview page. Please consider creating such a page, this could also
take over the paragraph with the links to wiki tutorials from the main
page. Please also add all specialities about the FreePascal Wiki like
configuration settings enabling/disabling some syntax elements, ...

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


Re: [fpc-pascal] Wiki Syntax Highlight

2007-06-07 Thread Johann Glaser
Hi!

Am Donnerstag, den 07.06.2007, 15:28 +0200 schrieb Vincent Snijders:
> Catalin Zamfir Alexandru schreef:
> > If there was a petition for this, I would have signed it. We need SYNTAX 
> > highlithing ... :P NOW. :D
> > 
> > If you do so, please use Geshi :D. It's the best and I use it a lot on 
> > theg33ks.com in my articles.
> 
> Does it work with mediawiki? Can you give a installation description for 
> mediawiki.

GeSHi also was my tip. I found it for MediaWiki
(http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi). Its
main page seems to be http://qbnz.com/highlighter/

Bye
  Hansi


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


[fpc-pascal] Wiki Syntax Highlight

2007-06-07 Thread Johann Glaser
Hi!

When reading Freepascal Wiki pages I find it quite tedious to read the
source blocks, because they are simple  blocks. Is it possible to
use a syntax highlighted code block?

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


Re: [fpc-pascal] Web Service Toolkit - Questions

2007-06-07 Thread Johann Glaser
Hi!

> > Studying the WST Wiki page
> > http://wiki.freepascal.org/Web_Service_Toolkit I found that it seems not
> > to be possible to serialize records. What is the difficulty implementing
> > that?
>
> None, I suppose, except that you must parse it :-)

I see. Are there any problems in the transport, i.e. does e.g. SOAP
support structured data?

> > How can I transport a record between two programs? I'd like to have the
> > same memory footprint (because it is forwarded to an USB device), so it
> > would be possible to pseudo-serialize the record into some byte stream
> > before transport.
> 
> You could convert your record to a class and transport that. The class
> is only needed in the transportation step, the rest of the code does not
> need to see it.

Do I have to put every record field as a member variable of the class or
is it enough to have one member variable of my record type?

> I think WST would greatly benefit from switching to pparser in the FCL.
> It would put all types available.

Do you think of the ws_helper program to parse a Pascal interface?

Bye
  Hansi


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


[fpc-pascal] Web Service Toolkit - Questions

2007-06-07 Thread Johann Glaser
Hi!

Studying the WST Wiki page
http://wiki.freepascal.org/Web_Service_Toolkit I found that it seems not
to be possible to serialize records. What is the difficulty implementing
that?

How can I transport a record between two programs? I'd like to have the
same memory footprint (because it is forwarded to an USB device), so it
would be possible to pseudo-serialize the record into some byte stream
before transport.

Thanks
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


Re: [fpc-pascal] Web Service Toolkit - Notify the Client

2007-06-03 Thread Johann Glaser
Hi!

> > Is it possible to delay a SOAP call a few seconds at the service
> > provider (until new data is available)? Hmm, this reveals the question
> > what are the timeouts for TCP/IP connection and for the web services? 
> 
> I think a few seconds are possible, a timeout is usually longer than
> that. The webservices do not specify any values for timeouts. I'm not
> sure whether the HTTP protocol has such definitions, but I would be 
> surprised if it had.

Thanks. I'll try it this way.

Bye
  Hansi


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


Re: [fpc-pascal] Web Service Toolkit - Notify the Client

2007-06-03 Thread Johann Glaser
Hi!

> > Usually the frontend does a remote procedure call to the backend. There
> > is one important problem I'm facing now. I want the backend (service
> > provider) to notify the frontend (service consumer) as soon as a new
> > measurement value has arrived. So this is the reverse direction of
> > communication.
> > 
> > Is this possible? Can you please point me to information how to
> > accomplish this?
> 
> This is not possible in SOAP, unless you do continuous polling.

Is it possible to delay a SOAP call a few seconds at the service
provider (until new data is available)? Hmm, this reveals the question
what are the timeouts for TCP/IP connection and for the web services? 

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


[fpc-pascal] Web Service Toolkit - Notify the Client

2007-06-03 Thread Johann Glaser
Hi!

I'm going to implement a data logger and a GUI frontend in FreePascal.
One (daemon) program gets data from a device connected via USB and
stores it to a file. A second program, the GUI frontend, connects to the
daemon and can retrieve the measured data and other stuff. Additionally
it can send commands to change the measurement settings. 

All this is quite a typical application for RPC, so I plan to use the
Web Service Toolkit with SOAP.

Usually the frontend does a remote procedure call to the backend. There
is one important problem I'm facing now. I want the backend (service
provider) to notify the frontend (service consumer) as soon as a new
measurement value has arrived. So this is the reverse direction of
communication.

Is this possible? Can you please point me to information how to
accomplish this?

Thanks
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


Re: [fpc-pascal] XML-RPC Client

2007-03-08 Thread Johann Glaser
Hi Michael!

> > Today I wanted to run the XML-RPC example programs rpcserv and rpccli.
> > The server starts well but the client doesn't seem to be up to date. I
> > played around quite some time now but to no success.
> > 
> > What is the current status of XML-RPC client implementation?
> > 
> > Why is there a {$IFDEF NEVERTRUE} around the TXMLRPCClient in xmlrpc.pp?
> 
> No idea. It's not up to date. But I suggest you use the Pascal Web Services 
> Toolkit;
> It's on the Lazarus CCR site, and I can give you an article on how to use it.
> (if you're german and read toolbox, it's in there, some time ago)

Thanks for the hint. Could you please send me the article?

Thanks
  Hansi


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


[fpc-pascal] XML-RPC Client

2007-03-07 Thread Johann Glaser
Hi!

Today I wanted to run the XML-RPC example programs rpcserv and rpccli.
The server starts well but the client doesn't seem to be up to date. I
played around quite some time now but to no success.

What is the current status of XML-RPC client implementation?

Why is there a {$IFDEF NEVERTRUE} around the TXMLRPCClient in xmlrpc.pp?

Thanks
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


Re: [fpc-pascal] Linux serial interface

2006-12-26 Thread Johann Glaser
Hi!

Am Dienstag, den 26.12.2006, 15:38 +0100 schrieb Rainer Stratmann:
> Am Dienstag, 26. Dezember 2006 14:07 schrieb Michael Van Canneyt:
> > On Tue, 26 Dec 2006, Rainer Stratmann wrote:
> > > How to open correct the serial interface ('/dev/ttyS0')
> >
> > As far as I know, this is a terminal, so the terminal emulator will mess up
> > the IO. You should open the raw device.
> 
> Isn't tty1 (without S) a terminal?

The ttySx devices also do a lot of terminal emulation stuff internally
(see e.g. stty(1) for how many things are possible, in your program you
have to do these with ioctl()).

Especially I have made the observation that flow control often is in
your way when you "just want to transmit data". Switch off flow control
completely (neither hardware nor software/XON/XOFF). Probably your
USB-serial converter has different default values for this and this is
why your program works with it.

Bye
  Hansi


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


Re: [fpc-pascal] Special math. functions (erf, erfc, ...)

2006-12-17 Thread Johann Glaser
Hi!

> The direct/inverse students' distribution and F-distribution are
> in the sources stdtrl.c and fdtrl.c of the Moshier's ldouble C library:
> 
> http://www.moshier.net/ldouble.zip
> 
> You can read about Cochran and SNK methods in many books, also available
> via web. A starting point for statistics resources may be the site
> 
> http://home.ubalt.edu/ntsbarsh/Business-stat/R.htm

Great!

Thanks a lot!

Bye
  Hansi


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


Re: [fpc-pascal] Special math. functions (erf, erfc, ...)

2006-12-16 Thread Johann Glaser
Hi!

Am Samstag, den 16.12.2006, 11:30 + schrieb [EMAIL PROTECTED]:
> Hi Hansi, 
> 
> > I'm searching for FreePascal implementations of some special
> > mathematical functions related to statistics like erf, erfc and some
> > other cumulative probability functions. Did anybody implement such
> > functions already (e.g. from the Numerical Recipies)?
> 
> Some functions are available here in the unit ustat.zip:
> 
> http://www.polarhome.com/~franco

Thanks for the hint! I can now calculate normal distribution and
chi²-distribution. Do you know where I can find documentation on how to
calculate the ciritcal values (i.e. inverse) of students' (t)
distribution, F-distribution and for some non-parametric tests
(Newman-Keuls-test, Cochran-Test, U-Test, ...)

Thanks
  Hansi


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


Re: [fpc-pascal] Special math. functions (erf, erfc, ...)

2006-12-15 Thread Johann Glaser
Hi!

Am Freitag, den 15.12.2006, 21:31 +0100 schrieb Florian Klaempfl:
> Johann Glaser schrieb:
> > Hi!
> > 
> > I'm searching for FreePascal implementations of some special
> > mathematical functions related to statistics like erf, erfc and some
> > other cumulative probability functions. Did anybody implement such
> > functions already (e.g. from the Numerical Recipies)?
> > 
> > Is it allowed to use the Numerical Recipies PDF files (e.g.
> > http://www.nrbook.com/b/bookcpdf/c6-2.pdf) and type ones Pascal program
> > one-by-one to the printed source code?
> > 
> 
> http://www.numerical-recipes.com/infotop.html#distinfo

Thanks for pointing this out. So, it is not possible to use the source
code from the PDFs to do anything "useful".

But I found the GNU Scientific Library (GSL) which includes a lot, and
especially some functions I'm seeking for. Did anybody write some
FreePascal bindings for that?

Bye
  Hansi


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


[fpc-pascal] Special math. functions (erf, erfc, ...)

2006-12-15 Thread Johann Glaser
Hi!

I'm searching for FreePascal implementations of some special
mathematical functions related to statistics like erf, erfc and some
other cumulative probability functions. Did anybody implement such
functions already (e.g. from the Numerical Recipies)?

Is it allowed to use the Numerical Recipies PDF files (e.g.
http://www.nrbook.com/b/bookcpdf/c6-2.pdf) and type ones Pascal program
one-by-one to the printed source code?

Thanks
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 

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


Re: [fpc-pascal] 64 bits

2006-03-20 Thread Johann Glaser
Hi!

> It is known that some people have a problem accessing  
> www.freepascal.org, but unfortunately no one knows the exact cause.  
> Some people think a certain kind of icmp packets are filtered by the  
> firewall in front of the machine that hosts www.freepascal.org  
> (something with fragmenting packets) and that this causes the problem.

Just as an idea: Did you think of ECN problems (Explicit Congestion
Negotiation, RFC 3168 http://www.rfc-editor.org/rfc/rfc3168.txt)? The
http://www.kernel.org/ site has a news entry (16.1.2002), which says:
--- schnipp ---
Please note that kernel.org uses Explicit Congestion Notification (ECN),
as defined in RFC 3168. Some broken firewalls or gateways may have
problem connecting to ECN-enabled servers. Please contact your firewall
or gateway vendor for necessary updates.
--- schnapp ---
So possibly a broken router which doesn't like the ECN bits in the IP
header is the cause of the problems. 

You can disable sending packets which use ECN on your Linux box by
  echo "0" > /proc/sys/net/ipv4/tcp_ecn

Bye
  Hansi


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


Re: [fpc-pascal] USB or RS-232 capability?

2005-01-14 Thread Johann Glaser
Hi!

> > Did you hear of libusb http://libusb.sourceforge.net/? I used it for
> > several projects, some of which use FPC too. If you want to have my
> > header translation to an FPC unit just drop me an email. 
> 
> It would be nice to have an entry in the contributed units page ?

Silly me, didn't think of that before. The unit is now contributed.

BTW: At the Miscellaneous group of units there is a contribution called
"fpcusb". Its link is currently dead. Probably this entry should be
removed or the author contacted.

BTW²: When I clicked the "Submit" button I first got an error message
that the "/contrib/add.php3" script is not present at the server. After
going back with my browsers "Back" button and again clicking the
"Submit" button it worked. I tried now to look at the contribution form
and again got the error message that add.php3 is missing.

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 


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



Re: [fpc-pascal] USB or RS-232 capability?

2005-01-14 Thread Johann Glaser
Hi!

> OK--that's helpful, guys. I'm still scratching my head on how to tackle 
> this project. Thanks.

Did you hear of libusb http://libusb.sourceforge.net/? I used it for
several projects, some of which use FPC too. If you want to have my
header translation to an FPC unit just drop me an email. 

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering
 http://www.johann-glaser.at/ 


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


Re: [fpc-pascal]How to access a parallel port?

2004-01-05 Thread Johann Glaser
Hi Rainer!

> I want to acces a parallel port (in Linux) from FPC 1.0.4 to control a
> connected LCD display. I did such things in DOS with TP/BP by accessing the
> hardware of the port directly, but this seems to be a little bit too close to
> the hardware in linux. Instead, I would like to access the parallel port
> through its device (i.e. /dev/lp0) and with some ioctrl() calls to access the
> handshake lines, too.
> 
> Should normally be no problem, but I have no idea where to start.
> 
> Does anybody have a sample code for that? Also, a easy to understand
> documentation of all parallel-port ioctrl() functions would be helpful.

I'm sorry that I can't help you out with ioctl()s. But: Some time ago I
was searching for that (/dev/parport should be the right thing) but
didn't find anything. Instead of that I had to directly program the
ports.

Look up my K7103 Digital Storage Oscilloscope project at 
  http://k7103.sourceforge.net/
and download the sources. In the source there is a file called
osziaccess.pas which does parallel port programming. There is an
"ioperm()" call too, this is important. Attention: you need root access
to use this call. That is the drawback of that method.

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering 
 http://www.johann-glaser.at/ 


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]MySQL 4.0 Files

2003-10-06 Thread Johann Glaser
Hi!

> They are available in source form only, not in binary form.

Ah, I see. That is why they are not in my .debs.

Why aren't they distributed in compiled form too?

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering 
 http://www.johann-glaser.at/ 


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]MySQL 4.0 Files

2003-10-06 Thread Johann Glaser
Hi!

> > Since then I updated to FPC 1.0.10. This doesn't bring these files any
> > more.
> 
> It does. I didn't test the source package, but the CVS repository
> definitely contains the 4.0 units.

Seems that they are forgotten in the fp-units-db Debian package.

Is it intended that the MySQL 4.0 binding is available in binary-only
distributions (.rpm, .deb, .tar.gz)? If yes then I'll write an EMail to
the .deb maintainer.

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering 
 http://www.johann-glaser.at/ 


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]MySQL 4.0 Files

2003-10-06 Thread Johann Glaser
Hi!

Some months ago I developed a program using MySQL as backend database.
This was MySQL 4.0 and therefore I used the MySQL 4.0 units. They have
been stored in /usr/lib/fpc/1.0.6/units/linux/mysql/ver40/. This was
with FPC 1.0.6.

Since then I updated to FPC 1.0.10. This doesn't bring these files any
more. Why is this and what do you suggest to use MySQL 4.0 with FPC
1.0.10?

Thanks
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering 
 http://www.johann-glaser.at/ 


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]ASCII plotting

2003-07-29 Thread Johann Glaser
Hi!

> I would like to include some simple "ascii plots" in my textual
> output files, like :

I'm sorry that I can't give you a unit. But look at "Maple"
(http://www.maplesoft.com/). For Linux I've got an X interface (xmaple)
and a text interface (maple).

The text interface does drawing plots as text. It even can draw 3D plots
in text mode! Probably you have the chance to examine this program. Then
try these feeatures!

Bye
  Hansi

-- 
Johann Glaser   <[EMAIL PROTECTED]>
   Vienna University of Technology
   Electrical Engineering 
 http://www.johann-glaser.at/ 


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal