Lazarus

Free Pascal => Beginners => Topic started by: kaimex on June 04, 2021, 07:49:20 am

Title: Serial unit missing
Post by: kaimex on June 04, 2021, 07:49:20 am
Hi,
I just tried to compile the example program "TestSerialPortCom" taken from the page
https://wiki.lazarus.freepascal.org/Hardware_Access#FPC_built_in_Serial_unit
The accompanying text says
"Another serial unit is part of FreePascal since version 2.2.2: just put 'Serial' in the Uses list. However there does not seem to be any documentation other than the Serial.pp source file and some discussions.
An example using FPC 2.6.2 on WIN7. "
I am (still) using FPC V 2.6.0 under Windows 7 Home Premium 64 Bit.
The Compiler responds with "Can't find unit serial used by TestSerialPortCom".
The search function of Explorer++ does not find serial.pp on the disk.
Why is it not included contrary to the above statement "since version 2.2.2" ?
Is it only included when installed on 32 Bit versions of Windows ?
How can I get the serial unit ?

Regards Kai
Title: Re: Serial unit missing
Post by: lucamar on June 04, 2021, 09:09:34 am
In 2.6.0 it seems to be a Unix-only unit:
Code: Bash  [Select][+][-]
  1. lucamar@Diana:~/temp/fpcbuild-2.6.0$ find ./ -iname "serial.*"
  2. ./fpcsrc/packages/amunits/src/coreunits/serial.pas
  3. ./fpcsrc/packages/libndsfpc/src/nds/arm7/serial.inc
  4. ./fpcsrc/rtl/unix/serial.pp
  5. ./fpcdocs/olinuxex/serial.pp

Probably also in previous releases, though I don't have any at hand to check it.

Is there any reason why you can't update to a more modern version? 2.6.0 is almost ten years old by now. Lots of water have passed under the bridge ;)
Title: Re: Serial unit missing
Post by: PascalDragon on June 04, 2021, 09:09:43 am
Looks like the wiki article you linked is not entirely correct. While the Serial unit for *nix systems exists since essentially forever (at least since conversion to SVN, thus before 2.2.2), the Serial unit for Windows was added only rather recently (namely 3.0.0, so not 2.6.2 either). You could try to take the unit from trunk (https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/rtl-extra/src/win/serial.pp?view=log) (click Download at the top). I think it should work with 2.6.0 as well as there weren't any fancy changes.
Title: Re: Serial unit missing
Post by: MarkMLl on June 04, 2021, 09:24:42 am
It went in at about 2.7.1, I think it sat in Mantis for quite a while after I submitted it. I forget the precise sequence of what went on 10+ years ago, but it's reasonable to expect that since it was in the development 2.7.1 it was backported into the (fixes release) 2.6.2, particularly if I was hassling people about it on the mailing list :-)

https://bugs.freepascal.org/view.php?id=18946

There have been no recent changes, but I don't think it's been tested against recent Windows. If OP does look at it, he should note the comments in the definition part about the change of flush/drain/sync behaviour, which is why I initially got involved.

I've considered some minor changes since then, but at present am not well set up for testing on Solaris which should also be good for the BSDs.

MarkMLl
Title: Re: Serial unit missing
Post by: PascalDragon on June 04, 2021, 10:09:42 am
It went in at about 2.7.1, I think it sat in Mantis for quite a while after I submitted it. I forget the precise sequence of what went on 10+ years ago, but it's reasonable to expect that since it was in the development 2.7.1 it was backported into the (fixes release) 2.6.2, particularly if I was hassling people about it on the mailing list :-)

It wasn't backported. The fixes tree for the 2.6.x series does not contain it.
Title: Re: Serial unit missing
Post by: MarkMLl on June 04, 2021, 10:20:27 am
Sorry, you're right: I was grepping over my source directories in haste.

MarkMLl
Title: Re: Serial unit missing
Post by: kaimex on June 04, 2021, 04:30:11 pm
Hi guys,
thank you for your immediate help,
especially to PascalDragon for the hint to the trunk download of serial.pp .
I have taken the latest version. It compiles with V 2.6.0, but so far does not "wait for answer", as it announces.
But so far I have not configured anything. Hopefully that can be fixed...
I installed V 2.6.0 actually on Oct. 18, 2012. Back then (and with still older versions before) I have been using undocumented FPC-code to capture exceptions or rather avoid crashes of my programs. The positions of the code I utilized changed from version to version, so I got lazy with updating...
May be, I don't need that anymore and could update to the most recent version.
Thanks again
Kai
P.S.: What I would very much wellcome, would be a unit to access an "old-time" 8-Bit-Parallel Port (Data, Control & Status) for interfacing to DIY-equipment under Win32 and Win64.
Title: Re: Serial unit missing
Post by: avra on June 04, 2021, 05:51:52 pm
P.S.: What I would very much wellcome, would be a unit to access an "old-time" 8-Bit-Parallel Port (Data, Control & Status) for interfacing to DIY-equipment under Win32 and Win64.
You should redirect your Delphi component search at Torry's first. Here is everything for direct port access: https://torry.net/pages.php?id=227.
Title: Re: Serial unit missing
Post by: jamie on June 04, 2021, 05:59:38 pm
get a LabJack
Title: Re: Serial unit missing
Post by: VTwin on June 04, 2021, 07:53:51 pm
Does Ararat Synapse meet your needs:

https://sourceforge.net/projects/synalist/

I use basic serial port functions in laz_synapse.pkg.

There is also:

https://forum.lazarus.freepascal.org/index.php/topic,20481.0.html
Title: Re: Serial unit missing
Post by: kaimex on June 05, 2021, 01:45:26 am
@avra: Thank you for making me aware of Torry's page on direct port access. However, I don't see any solution that is supposed to work under 64-Bit Windows. I have tried several tools in the past. Some work under 32-Bit windows. Some have annoying side effects (e.g. after userport.exe has started its port-access driver, all old 16-Bit programs running under ntvdm won't work). I could not find a solution that works under Windows 7 Home Premium 64 Bit. Even tools that others have reported to do it, did not in my environment.
@jamie: I don't want to spend money on LabJack, I want to be able to use my own old equipment, that was formerly hooked to and controlled via the Printer-Port.
64-Bit Windows appears to me like Ransom-Ware: My PC has a dedicated PCI-Parallel-Port card inserted that the system won't use, but Microsoft does not allow me to use it without extra cost for special certified drivers.
@VTwin: Thanks for pointing to Synapse. I have had a very brief look at it. Presently FPC's "built-in" serial unit does what I wanted.
Thanks
Kai
Title: Re: Serial unit missing
Post by: avra on June 05, 2021, 03:22:00 am
I don't see any solution that is supposed to work under 64-Bit Windows.
All these can be found from that page and all work under 64bit:
https://www.entechtaiwan.com/dev/port/index.shtm
https://www.entechtaiwan.com/dev/hw32/index.shtm
http://www.zealsoftstudio.com/ntport/
https://www.winsoft.sk/ioport.htm

You could also take a look at these:
https://github.com/changguangyu/DelphiMSR
http://pascal.hansotten.com/delphi/driverlynx-dlportio-and-windows-7-and-8-and-64-bit/
https://www.highrez.co.uk/Downloads/InpOut32/
https://wiki.freepascal.org/Hardware_Access#Parallel_Communication

after userport.exe has started its port-access driver, all old 16-Bit programs running under ntvdm won't work
So you expect that ntvdm and direct port driver both work while trying to race for direct access to the same physical port? Highly unlikely without them cooperating and using single gateway for port access, which doesn't seam to happen. Did you try to run your old 16-bit programs under dosbox or virtualbox instead?

I could not find a solution that works under Windows 7 Home Premium 64 Bit. Even tools that others have reported to do it, did not in my environment.
Then move to Windows 32 bit or Linux if that is so important. Alternatively, you could use some Arduino (or similar) for direct access and talk to it from your x64 pc os via serial/usb, bluetooth or ethernet. Some FTDI chips have fast GPIO which can be also used. Take a look at bit banging example here: https://ftdichip.com/software-examples/code-examples/delphi-examples/
Title: Re: Serial unit missing
Post by: MarkMLl on June 05, 2021, 09:21:19 am
I have taken the latest version. It compiles with V 2.6.0, but so far does not "wait for answer", as it announces.

What doesn't wait for answer? Is this the wiki example or something in serial.pp?

MarkMLl
Title: Re: Serial unit missing
Post by: kaimex on June 05, 2021, 09:39:19 am
Hi avra,
thank you for your additional advice.
As far as I can remember, I already tried
directio/giveio.sys/totalio.sys, gwiopm.sys, inout32.dll and inpoutx64.dll, userport.exe/userport.sys, WinIo v3.0, port.dll .
At least WinIo and inpoutx64.dll are reported to work under 64 Bit Windows, but they don't work on my Windows 7 Home Premium 64 Bit PC.

I'll check the other tools that you listed, whether one of those does the job.

I did not try to access I/O-ports concurrently via userport and programs running under ntvdm. I just observed that all old 16 Bit Programs (e.g. those compiled with Turbo Pascal 6 & 7 under Windows XP and TP6 & TP7 themselves are blocked when userport.sys has been started. They do not respond to keyboard or mouse with the exception of the close-window-button, just "hang" in the entry display.

I am using Windows 32-Bit (XP on 3 PCs and Win 7 on a netbook), Linux Mint 20 on a laptop and Windows 7 64 Bit on a quadcore desktop PC. I have no (serious) problems to access the Parallel port with userport.sys under Windows XP with programs written with FPC. I just want to access the parallel just as well on my "work-horse", the quadcore 64-Bit PC.
The initial question for the serial unit arose from my arrempt to communicate with a µP-board via V24, possibly as a work-around for the denied access to the parallel port.
I am using one of those ubiquitous PCI Parallel-Port boards from Sunix. They supply certified drivers for use as Printer Port (LPTxx). But these drivers do not allow transparent control or read-out of the data/control/status-port bit values. It is in principle all there, but you don't get it.
Printing is done on this PC via USB. The sytem does not use the parallel port if I do not define it as a another printer port. So there is no danger of collision with other processes on the PC. It is no security leak as I am the only user. So no reason at all to deny access. Sunix might as well supply a certified driver to access the ports in a way as was possible during DOS-times.
Regards
Kai

Addendum to MarkMLI:
The example program ends with "Waiting for an answer" (waits for a CR from the other end of the V24 connection). It did not wait after my first attempt to run that program because nothing was configured nor connected. In the meantime I have connected a µP-board, "harmonized" the V24-parameters on both sides and now it works fine. Thank you.
Title: Re: Serial unit missing
Post by: MarkMLl on June 05, 2021, 09:51:23 am
OP: sorry, I'm stressed by a growing to-do list right now so this will be curt.

For various reasons I have spent a long time hamstrung by older operating systems, and in some cases by old code which demanded direct hardware access. So "I feel your pain" but here's how things are:

Unless you have a very old version of Windows there is no real reason why you should not be able to upgrade to a newer version of FPC. If you're running something pre-2000 you might have problems on account of limited support for non-Western character sets, but that's the main cutoff.

Almost all recent operating systems, i.e. anything with multitasking and memory management, limit access to hardware. A substantial reason for that is security: the more loopholes in the system, the greater the risk that somebody will do something unexpected to your detriment: and they might only need a webpage or an MS Word document to do so. So you really do have to start looking for alternatives to direct hardware access.

MarkMLl
Title: Re: Serial unit missing
Post by: PascalDragon on June 05, 2021, 10:50:02 am
I did not try to access I/O-ports concurrently via userport and programs running under ntvdm. I just observed that all old 16 Bit Programs (e.g. those compiled with Turbo Pascal 6 & 7 under Windows XP and TP6 & TP7 themselves are blocked when userport.sys has been started. They do not respond to keyboard or mouse with the exception of the close-window-button, just "hang" in the entry display.

I/O port are exclusive resources. So if userport.sys reserves them then NTVDM simply can't access them, because they're already in use.

I am using Windows 32-Bit (XP on 3 PCs and Win 7 on a netbook), Linux Mint 20 on a laptop and Windows 7 64 Bit on a quadcore desktop PC. I have no (serious) problems to access the Parallel port with userport.sys under Windows XP with programs written with FPC. I just want to access the parallel just as well on my "work-horse", the quadcore 64-Bit PC.
The initial question for the serial unit arose from my arrempt to communicate with a µP-board via V24, possibly as a work-around for the denied access to the parallel port.
I am using one of those ubiquitous PCI Parallel-Port boards from Sunix. They supply certified drivers for use as Printer Port (LPTxx). But these drivers do not allow transparent control or read-out of the data/control/status-port bit values. It is in principle all there, but you don't get it.
Printing is done on this PC via USB. The sytem does not use the parallel port if I do not define it as a another printer port. So there is no danger of collision with other processes on the PC. It is no security leak as I am the only user. So no reason at all to deny access. Sunix might as well supply a certified driver to access the ports in a way as was possible during DOS-times.

That's simply not how things work in modern operating systems. It doesn't matter whether you're the only user or not, it's simply a bad thing (TM) to provide direct, unrestricted hardware access and OSes need to provide for all users, not only you. Thus you need to use suitable device drivers that provide the access of the I/O ports from kernel space to user space through some controlled API. You'll probably have to check which ports your PCI card requires and then have those ports mapped by some utility like userport.sys or whatever (I've never used them so I can't comment how they need to be configured or used).
Title: Re: Serial unit missing
Post by: kaimex on June 05, 2021, 10:56:00 am
Hi MarkMLI,
I will consider upgrading to the new FPC versions in the future. In some of my programs that are still undergoing "updates" now and then I will have to look after the special exception handling that depended on internal details of V2.6.0.
None of my Windows PCs is connected to the internet or other public access. I am the only user. So I cannot see any security risk by getting access on the bit-level to the I/O-lines of the parallel port.
It is really only a question of the extra money required to get a "trusted certificate".
I have just found the package "WinIo v3.0" on the hard disk of my "workhorse" PC. It seems seems that I actually did not yet try that one for "Direct Hardware Access" under 64-bit Windows although the author assures that it works.
He explains that 64Bit-Windows only load device drivers that come with a "code signing certificate". His WinIo64.sys  is, however, signed with a "self-signed certificate" and can only be used on Windows running in a special "test" mode (with boot option "TESTSIGNING ON").
So far I could not get comfortable with that approach.
As I already said once, Sunix supplies certified drivers for use as printer port, they might as well supply drivers that grant access to the ports on the bit level for the PC/electronics-hobbyists.
Regards
Kai

@PascalDragon: As I alread explained ALL programs running "with the help" of ntvdm are blocked in their initial display , whether they access ports or not . Even the old TP6 & TP7 compilers. That need not be so. It would be totally sufficient, that concurrent port access be blocked, but not any other program excecution.

On my PCs I am "all users" together with the system. So there is no reason at all to keep me from using a parallel port that I have plugged in for hobby purposes. And, by the way, nobody talks about security issues anymore, as soon as  I have a "trusted certificate" (other words for expensive) for a driver doing just that. 
Security arguments could not explain, why access is denied on 64Bit systems and allowed without extra certificates on 32Bit systems.
Title: Re: Serial unit missing
Post by: MarkMLl on June 05, 2021, 10:57:51 am
That's simply not how things work in modern operating systems. It doesn't matter whether you're the only user or not, it's simply a bad thing (TM) to provide direct, unrestricted hardware access and OSes need to provide for all users, not only you.

Where "users" in this case includes all the background stuff of which an untutored owner is unaware.

Sorry OP: you either stick with old operating systems and risk being left in the cold due to lack of security patches etc., or you learn modern programming techniques. Simple as that.

MarkMLl
Title: Re: Serial unit missing
Post by: PascalDragon on June 05, 2021, 11:05:32 am
I have just found the package "WinIo v3.0" on the hard disk of my "workhorse" PC. It seems seems that I actually did not yet try that one for "Direct Hardware Access" under 64-bit Windows although the author assures that it works.
He explains that 64Bit-Windows only load device drivers that come with a "code signing certificate". His WinIo64.sys  is, however, signed with a "self-signed certificate" and can only be used on Windows running in a special "test" mode (with boot option "TESTSIGNING ON").
So far I could not get comfortable with that approach.

On the one hand you say that you don't worry on security issues, but on the other hand you don't want to enable TESTSIGNING ON despite this being the standard approach when you have unsigned or self signed drivers... ::)

As I already said once, Sunix supplies certified drivers for use as printer port, they might as well supply drivers that grant access to the ports on the bit level for the PC/electronics-hobbyists.

Then ask Sunix.
Title: Re: Serial unit missing
Post by: MarkMLl on June 05, 2021, 11:07:53 am
Hi MarkMLI,
I will consider upgrading to the new FPC versions in the future. In some of my programs that are still undergoing "updates" now and then I will have to look after the special exception handling that depended on internal details of V2.6.0.

You should not be writing code that depends on internal details like that. PascalDragon will vouch for the fact that I've historically been tied to old OSes and hardware, so I feel I'm in a good position to tell you that. So BE TOLD (please :-)

Quote
None of my Windows PCs is connected to the internet or other public access. I am the only user. So I cannot see any security risk by getting access on the bit-level to the I/O-lines of the parallel port.
It is really only a question of the extra money required to get a "trusted certificate".
I have just found the package "WinIo v3.0" on the hard disk of my "workhorse" PC. It seems seems that I actually did not yet try that one for "Direct Hardware Access" under 64-bit Windows although the author assures that it works.
He explains that 64Bit-Windows only load device drivers that come with a "code signing certificate". His WinIo64.sys  is, however, signed with a "self-signed certificate" and can only be used on Windows running in a special "test" mode (with boot option "TESTSIGNING ON").
So far I could not get comfortable with that approach.
As I already said once, Sunix supplies certified drivers for use as printer port, they might as well supply drivers that grant access to the ports on the bit level for the PC/electronics-hobbyists.

With your level of expertise and understanding you should not be getting involved with that stuff. In particular, if something which you do is considered to be abusing a certificate you'll be very unpopular with just about everybody including your bank... do you want to be blacklisted because people think you're facilitating malware?

Get yourself e.g. a USB-connected interface card and use that, see e.g. https://hackaday.com/2018/02/21/linux-adds-ch341-gpio/ for which I believe Windows drivers are available, or learn to use an "Internet of Things" device... you'll still need to familiarise yourself with a library interface but you'll find people around here will do their best to help.

MarkMLl
Title: Re: Serial unit missing
Post by: avra on June 05, 2021, 04:42:18 pm
I'll check the other tools that you listed, whether one of those does the job.
https://github.com/changguangyu/DelphiMSR
Did you already check this one? That code has both 64bit and 32bit reported to work just 3 years ago. I know it's about MSR registers, but if you look at https://github.com/GermanAizek/WinRing0 it seams to support direct I/O port access too (like ReadIoPortByte) which you could try to add to DelphiMSR pascal wrapper.


Btw, do you know that you need to produce 64bit application to work with 64bit driver which (for some drivers) needs to be installed first? What exact FPC/LAZ version you use while trying 64bit windows driver to work?
Title: Re: Serial unit missing
Post by: kaimex on June 05, 2021, 10:08:34 pm
@avra:
No, I had not yet "heard" about DelphiMSR before.
The last thing that I tried was inpout32.dll & inpoutx64.dll in mid-May. And before that userport.exe/sys, which I am presently using successfully on an old Windows XP laptop (in conjunction with programs compiled by FPC v2.20 :-) ). On the 64Bit Windows 7 Home Pemium PC this does not work.
The inpout-package installs both dlls.
I have tested with FPC v2.6.0  using the FreePascal IDE for Win32, not with Lazarus.
I am not doing any 64-Bit programming.
My test program uses functions exported by inpout32.dll. An attempt to use those of inpoutx64.dll did not work at all.
The strange thing with the inpout32.dll functions is that I/O-writes & reads initially work but after a certain number of calls I get either error 216 (general protection fault) or error 217 (unhandled exception) or even other error numbers, that are not ducumented in FPC's list. The maximum number of calls I could make was something like 53, in the last program version it was only 21. Depends somehow on the program formulation. I could not reproduce the "53-case". In 2012 people reported that it works on Win64. So far I cannot confirm that for my system.

@PascalDragon:
The recommendation to ask Sunix for a driver appears inadequately unfriendly to me.
My positive approach to the desire to make parallel ports available for uses other than the classical printer connection would be to engage some knowledgeable people to write a suitable driver and gather money from the FPC community to be able to afford a signed/trusted certificate.

Regards Kai
Title: Re: Serial unit missing
Post by: avra on June 06, 2021, 12:12:03 am
For the last time:

you need to produce 64bit application to work with 64bit driver
Title: Re: Serial unit missing
Post by: kaimex on June 06, 2021, 07:19:21 am
Thank you for emphasizing that, but it is not in line with my intentions:
For my applications I do not need 64Bit programming/drivers.
I just need 32Bit drivers working on 64Bit Windows.
The 32Bit drivers written for Windows XP (and above but below Windows 7) do not work on 64Bit Windows due to the extra restrictons Microsoft has introduced.
May be it's just the missing certificate. That's why I am inclined to call that ransom.

Thank you for your valuable hints to other driver candidates that I might try.
Regards Kai
Title: Re: Serial unit missing
Post by: Re-searcher on June 06, 2021, 09:47:35 am
@kaimex

Hi Kai,
Have also worked with serial and parallelport on pc with 8bit,16bit,32bit and 64bit

Go to the BIOS from your PC
Place the parallelport on bidirectional

I have found this  for you :

http://www.sunix.com/en/support.php?item=dd
https://drp.su/en/devices/chipset/sunix

good luck

Regards,
Erik
Title: Re: Serial unit missing
Post by: PascalDragon on June 06, 2021, 12:51:52 pm
The recommendation to ask Sunix for a driver appears inadequately unfriendly to me.

You were the one who was complaining that Sunix does not provide suitable drivers for direct port access. Well, they know their hardware and they are probably able to sign their drivers. So for me it is a logical step to at least ask them directly.

Thank you for emphasizing that, but it is not in line with my intentions:
For my applications I do not need 64Bit programming/drivers.
I just need 32Bit drivers working on 64Bit Windows.
The 32Bit drivers written for Windows XP (and above but below Windows 7) do not work on 64Bit Windows due to the extra restrictons Microsoft has introduced.
May be it's just the missing certificate. That's why I am inclined to call that ransom.

That has nothing to do with "restrictions Microsoft has introduced". Kernel mode code on a 64-bit OS can only run 64-bit code. Thus if you have a 32-bit driver that simply can not work. It's essentially as if you'd try to run ARM code on a x86. For user mode you can use 32-bit code, cause there the OS can switch that user task into a virtual 32-bit mode (it's more complex than that, but it sums it up rather well).
So, no, it's not "just the missing certificate". You need to use a 64-bit driver. There is no way around this.

(Though I do not agree with avra that a 64-bit user space utility is necessarily required; if the driver is designed correctly it can work with both 32- and 64-bit user space applications)
Title: Re: Serial unit missing
Post by: kaimex on June 06, 2021, 05:16:17 pm
Hi,
in the meantime I have tried the WinRing0 stuff that avra made me aware of.
It behaves very much similar to the inpout32.dll aproach:
Depending on details of the code I can make 25 (1 write, 2 reads) or 34 (1 write, 1 read) or 51 (1 write) read/writes to the data- and status-port of the parallel port (Base-address C010) until I get an "file not open" (5) or "file not found" (2) error. The behaviour also depends on whether debug-output ist written just by writeln or by "writeln(f," (where f has been created by assigncrt(f)) to the cmd-window.
It appears as if somebody in the background is counting IO-accesses as file-IO and lifts the stop sign after a certain number. Another strange thing is that after GetDllVersion & GetDriverVersion an attempt to output the result in hex format leads to a crash with error 217.
The same happens after reads to the base-address +1...7
So a little bit works, but it is not really usable.
So far I have no idea, how to get rid of the file-related crashes.
This test was done with the WinReg0.dll. I have put WinReg0.dll, WinReg0.sys, WinReg0x64.dll and WinReg0x64.sys into the application directory, without any further registration or installation.

@PascalDragon: Is a FPC 64 Bit version available that I could try to test your understanding of the subject ?

@Erik: Thank you for your hints. I'll look into that. I have read the Sunix information about installion as printer interface. There was a section about Multi-function-adapter, but not really helpful apart from this info : "LPT3, IO-range:C010-C017 & C000-C007". As far as I remember I could switch the data port from output to input already under inpout32.dll, but just as narrated above only for a limited amount of calls.

Regards Kai 
Title: Re: Serial unit missing
Post by: jamie on June 06, 2021, 05:35:41 pm
Limited calls to me sounds more like wrong calling convention or not handling the HANLDES to resource correctly..
Title: Re: Serial unit missing
Post by: kaimex on June 06, 2021, 06:25:17 pm
@jamie: I am just using the exported DLL-functions. There are no handles involved, that is buried in the Dll.

It is not clear to me. whether registration of the DLL might make a difference. The author of the package does not talk about that. He writes about a WinReg0.lib that is nowhere in the package nor on the GitHub DelphiMSR pages.

@Erik: I have looked into the 2 Sunix-links. Their driver-package has no driver for my card.
It seems to be an (PAR)4008T ver 2.1 with a SUN1888 chip, several (or more :-) ) years old.
Their site lists PAR4008A, PAR4008AL, PAR4008B & PAR4008BL, but has no drivers for them.
The driver package behaves very brutal: irrespectively of whether you opt for driver installation ("we will speed up your computer") or something else, its GUI captures the whole screen and "analyzes the system" or "prepares installation" until the progress bar has reached about 95%, then it hangs. Luckily the seeminly dead window can be closed . Sunix seems to be one of the companies that only support their current or most recent cards.

I have not yet looked into the BIOS with respect to "bidirectional" because I am listening to music played from this PC. I'll do that later.

Regards Kai
Title: Re: Serial unit missing
Post by: kaimex on June 06, 2021, 09:59:39 pm
Go to the BIOS from your PC
Place the parallelport on bidirectional
I have looked into the BIOS, cannot find anything about the Parallel Card.
To my knowledge Parallel_Port cards have been bidirectional since PS2_days (for more than 20 years now). The direction of the data_port is controlled by bit 5 (of 0-7) of the control_port (base_address+2). It is not the job of the BIOS to handle that.

Regards Kai
Title: Re: Serial unit missing
Post by: PascalDragon on June 07, 2021, 08:59:00 am
@PascalDragon: Is a FPC 64 Bit version available that I could try to test your understanding of the subject ?

As I said, I doubt that you need to have a 64-bit userspace application, to interact with a 64-bit driver (and what you're writing is a user space application). That said you can download the combined FPC 3.2.2 for i386 and x86_64 (named fpc.3.2.2.win32.and.win64.exe from here (https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/). For older versions we provide a cross compiler for x86_64 as well that you can install additionally to the i386 one.
Title: Re: Serial unit missing
Post by: kaimex on June 07, 2021, 04:11:40 pm
I am not familiar with that 64Bit stuff.
I just empirically tried inpout32.dll and inpoutx64.dll with a program written in FPC v2.6.0:
with inpoutx64.dll it did not work at all,
with inpout32.dll read/writes to the PCI-parallel-port worked for a limited number of times (24 to 57) depending on details of the program.

Another question:
Can FPC v3.2.2 coexist with older versions on the same PC ?
In other words: are FPC installations independent ?
If yes, I would like to keep the old v2.6.0 version .

I am "a burnt child" from my experience with Audacity: different versions interfere due to common directories on drive C:.

Regards Kai
Title: Re: Serial unit missing
Post by: af0815 on June 07, 2021, 04:58:52 pm

Another question:
Can FPC v3.2.2 coexist with older versions on the same PC ?
In other words: are FPC installations independent ?
If yes, I would like to keep the old v2.6.0 version .
Look for fpcupdeluxe. Yes it is possible to handle more than one fpc/Lazarus on one PC without a problem. But you must have a little knowledge about the things you do.
Title: Re: Serial unit missing
Post by: kaimex on June 07, 2021, 10:00:20 pm
Thank you for directing my attention to fpcupdeluxe.
Does this hint mean, that without the use of fpcupdeluxe two different installations of FPC would interfere ?

Additional question:
Does fpcupdeluxe organize offline installation such that 2 or more FPC installations can coexist,
or does it require internet connection for online installations ?
I can only use Windows tools suitable for offline work.

Regards Kai
Title: Re: Serial unit missing
Post by: af0815 on June 08, 2021, 07:48:19 am
Thank you for directing my attention to fpcupdeluxe.
Does this hint mean, that without the use of fpcupdeluxe two different installations of FPC would interfere ?

Additional question:
Does fpcupdeluxe organize offline installation such that 2 or more FPC installations can coexist,
or does it require internet connection for online installations ?
I can only use Windows tools suitable for offline work.

Regards Kai
On windows you can set fpc and lazarus on a bare metal pc with fpcupdeluxe. For the installation a connetion to the internet is a must have, because fpcupdeluxe load all need tool, software, components by itself down. After you finish your installation, offline work is possible. fpcupdeluxe, fpc and lazarus need no connection to the internet. Offline work is no problem, only if you want to update your installation you have to go online, because svn or git need it to synchronize the sources.

You can have a lot of installations of the couple fpc/lazarus. Each installation is seperated, but you MUST start Lazarus with the Desktopicon (or the right parameters) to say where are the correct installation. Dont add fpc or Lazarus in the path, this is a no go. And dont use path with space or special characters. And be aware, windows show often other names in the explorer and use other names on the file system, this is a one of problem with the user home dir. On some systems you have problems with fpc/lazarus because windows use spaces in the real dir or filename.

I have 5 installations side by side without a problem, but NO DEFAULT installation, so all is seperated. If you can open a Pascal Project with a double click you have a default installation and this can make confusuion. So deinstall all installed fpc/Lazarus to to avoid this situation. This is my best pratic, to work for a long time without headache.
   



 
Title: Re: Serial unit missing
Post by: PascalDragon on June 08, 2021, 09:11:01 am
Does this hint mean, that without the use of fpcupdeluxe two different installations of FPC would interfere ?

No, they wouldn't. Everything is contained inside the installation directory and it will depend on which version you put in your PATH. If you use the Windows installers provided by us, you don't need fpcupdeluxe if you merely want two separate installations.
Title: Re: Serial unit missing
Post by: kaimex on June 08, 2021, 05:09:46 pm
you can download the combined FPC 3.2.2 for i386 and x86_64 (named fpc.3.2.2.win32.and.win64.exe from here (https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/). For older versions we provide a cross compiler for x86_64 as well that you can install additionally to the i386 one.
On the SourceForge site I see the combined fpc-3.2.2.win32.and.win64.exe and a cross compiler for the same version : fpc-3.2.2.i386-win32.cross.x86_64-win64.exe.
I wonder why.
Starting from the FPC download page I am offered the choice of SourceForge & Download mirrors in Hungary and Canada.
The latter two sites both state:
"Download native compiler
There is no native compiler available for x86_64 Win64. You have to use a cross-compiler.
Download cross-compiler running on another host
This cross-compiler runs on another host and needs the corresponding native compiler as a prerequisite."
This confuses me. Is this outdated information ?

By the way: do I have to use Lazarus or can I stay with  the old textmode IDE ?

Regards Kai
Title: Re: Serial unit missing
Post by: Re-searcher on June 08, 2021, 05:36:40 pm

Hi Kai,
See this site :

https://www.lazarus-ide.org/index.php?page=downloads

Greetings,
Erik
Title: Re: Serial unit missing
Post by: PascalDragon on June 09, 2021, 09:15:13 am
you can download the combined FPC 3.2.2 for i386 and x86_64 (named fpc.3.2.2.win32.and.win64.exe from here (https://sourceforge.net/projects/freepascal/files/Win32/3.2.2/). For older versions we provide a cross compiler for x86_64 as well that you can install additionally to the i386 one.
On the SourceForge site I see the combined fpc-3.2.2.win32.and.win64.exe and a cross compiler for the same version : fpc-3.2.2.i386-win32.cross.x86_64-win64.exe.
I wonder why.

It's the first time we provide the combined installer. Before that we've only provided the separate installers. But considering that nowadays most Windows are 64-bit it makes sense to provide a combined one. Please note if you use the cross installer you first need to install fpc-3.2.2.i386-win32.exe.

Starting from the FPC download page I am offered the choice of SourceForge & Download mirrors in Hungary and Canada.
The latter two sites both state:
"Download native compiler
There is no native compiler available for x86_64 Win64. You have to use a cross-compiler.
Download cross-compiler running on another host
This cross-compiler runs on another host and needs the corresponding native compiler as a prerequisite."
This confuses me. Is this outdated information ?

No, it's not. It's still as valid as ever. We only provide a Win64 cross compiler (even inside the combined installer), cause with a Win64 native compiler it's not possible to compile a cross compiler for i386. Lazarus for example provides a native Win64 compiler (the compiler itself can perfectly well be compiled as a native Win64 application). In most cases it won't matter if you use a native Win64 compiler or a cross compiler. It will only matter if you compile really large programs and require more than 3 GB of address space to compile and link.

By the way: do I have to use Lazarus or can I stay with  the old textmode IDE ?

You can stay with the text mode IDE though you will have to use the fp.exe provided with the installer (there will also be a second executable that provides the 64-bit IDE, because the IDE has the compiler built in, though right now I don't know its name).
Title: Re: Serial unit missing
Post by: kaimex on June 09, 2021, 08:17:42 pm
Hi,
Re-searcher Erik, who in reply #24 supplied a link to the Sunix support site for driver downloads has asked by personal message whether I could send a parallel port driver.
You can get drivers for currently sold parallel port cards with the SUN1999 chip from that site
http://www.sunix.com/en/support.php
by selecting "Method 1", Product name "PAR5008A" or "PAR5008R", which leads to a list of driver packages for  different operating systems.
Older cards like PAR4008... are also in the product name list, but result in an empty driver list.
I found drivers suitable for older cards with the SUN1888 chip like the PAR4008... on this site:
https://drivers.softpedia.com/get/MODEM/OTHER-MODEM-DRIVERS/Lenovo-ThinkStation-P700-Sunix-Parallel-Card-Driver-8-1-5-0-for-Windows-10-64-bit.shtml
The package is called k1par01us17_ts.exe (there is also a k1par01us17_ts.txt) and containes driver version 8.1.5.0. On the Sunix site there is also a 8.1.5.0 driver under the PAR5008 product line (apart from 8.2.0.0 and 9.2.2.0), but I cannot tell, whether that works with the SUN1888 chip.

Among the support software for the PAR5008 product is also a tool called "ParallePortRegisterReadWriteTool_x86_x64" which allows to peek & poke manually in the registers of the parallel cards. This also works with my ...4008... card. This program/package comes with the inpout32.dll & inpoutx64.dll and an installer. It is obviously the same inpout... package as supplied elsewhere. I had installed before from the original source and see with Microsoft's "SystemInfo" under "Software environment", "System drivers" that inpoutx64.sys is installed as an automatically started kernel driver.
A 32Bit application written with FPC can only use the inpout32.dll, it won't load the inpoutx64.dll.
My test application presently either does 14 IO-writes  before appcrash (error 0x80000002) or 2342 IO-writes and does its crash only when the program wants to terminate anyway (error 40010006).
I have no idea, what makes the difference.

Regards Kai
Title: Re: Serial unit missing
Post by: kaimex on June 12, 2021, 05:44:29 pm
Update:
In the meantime I have found two code versions running at least half a million times until I stop the test without any crash. Both can use the WinRing0 approach and the inpoutxx approach (which seem to be very similar) to direct parallel port access.
Right now I am successfully driving an old RAM-based EPROM-simulator with it. The "RAM-PROM" is the program memory during program development on the PC for a µP-board, which communicates measurement results via V24/RS232 to the same PC.
Nonetheless, success or crash with WinRing0 or inputxx seems to be pure (bad) luck. Adding another IO-access or making other changes to the code may result in failure after some IO-operations.

Kai
 
Title: Re: Serial unit missing
Post by: Re-searcher on June 13, 2021, 04:57:22 pm
I have two multi io cards here :

For 8bit isa slot : UM8250B (serial) and for parallel port : logic ic from te 74 series


For PCI slot : 2 serial ports and 1 parallel port
Moschip MCS9835CV
https://elcodis.com/parts/6435091/MCS9835CV.html
http://datasheet.elcodis.com/pdf2/100/77/1007731/mcs9835.pdf


Ask sunix the data sheet for you sun1888 IC.

There may be differences between you and my IC.

Erik

TinyPortal © 2005-2018