Re: Explain this about threads

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jon Slaughter wrote:
Because it uses a specific protocol AFAIK so you cannot use any deviced attached to the port(only those deviced designed to communicate on it).

Have you tried? The basic parallel port driver should be protocol agnostic, AFAIK. You open it with CreateFile(), and it's just a read/write stream.

The driver should take care of all the data integrity stuff, while your application can worry about the application protocol.

I don't know how to do this using managed code, but I think that using p/invoke to get at the unmanaged API would be a lot easier than the hoops you're trying to jump through now.

I'm not aware of any non-spin-wait mechanism that will allow you to time the interval between individual calls to out. The best you can do with the mechanisms available is to ensure an _average_ data rate and even there, without some kind of buffering support, you still have the problem of having to not send data too fast.

huh? How can you ensure an average data rate but not ensure it will not be to fast? Its very easy to ensure a maximum speed... its impossible to ensure a mimimum speed.

Ensuring an average data rate is easy. You send some fixed amount of data, and then you wait an appropriate amount of time. The amount of time you wait and/or measure may be long, but there will always be an amount of time you can select that provides an accurate-enough average data rate even using the standard Windows timing mechanisms.

Whether this is practical in your case, I can't say. It really depends on why the timing is so critical to you. But generally speaking, it's just not a problem. Average is just that: average. If you average over a long enough time period, it's trivial to achieve any arbitrary average. You just need to be able to select a long enough time period.

[...] What I'm trying to achieve is a way to send data at an average rate so this can be quantitatively adjusted by the user. So if the user wants 20khz he will get about 20khz and not 50khz or 5khz(on average).

Well, over what time period is it necessary that this average data rate be achieved? Will the user care if the data transmission is in short, rapid bursts that over a second or more still average out to the rate they've selected?

Or is the requirement more sensitive than that?

[...]
Sure... but if you can come up with a better way then I'm all ears. This is the method used by all the programs that I am aware that are doing similar stuff to what I need.

For example? What Windows programs are you talking about that use this library to access the CPU's i/o port directly, rather than going through CreateFile to access the parallel port? How have you verified that they use this technique? And if they use this technique, how to _they_ deal with the data throttling issues?

Knowing answers to those questions would go a long way to better understanding your specific situation.

Although I have no idea how SPP mode works with clocked data for, say, a printer. I'm not sure if they just bit-banged or what. Obviously the newer modes get around this by having the hardware deal with it but they then introduce there own protocols that do not work for me cause the devices I'm attaching do not understand them.

As far as I know, a parallel printer driver does not implement its own parallel port i/o. It uses the built-in Windows parallel port driver, and relies on that driver to deal with the low-level issues. This is true even for the older parallel port modes (often selectable in BIOS, so Windows has to support them).

If it were me, I would use unmanaged code based on CreateFile using the parallel port as my first attempt. Only if that didn't allow me to achieve what I wanted would I mess around with this lower-level stuff.

Pete
.



Relevant Pages

  • Re: Explain this about threads
    ... The driver should take care of all the data integrity stuff, ... application can worry about the application protocol. ... Ensuring an average data rate is easy. ... CreateFile to access the parallel port? ...
    (microsoft.public.dotnet.languages.csharp)
  • ~~~~~~~~~~~~~~~ PARALLEL PORT ~~~~~~~~~~~~~~~
    ... qbasic parallel port programs ... usb parallel port adaptor ... parallel printer port to usb adapter ... logitech quickcam parallel port driver ...
    (sci.psychology.personality)
  • Re: Printing in CE.NET without drivers
    ... The parallel port is not supported in the emulator, ... If your device has a parallel port driver then it may wll be LPT1: ... > the windows ce emulator but always get an "device not existe" windows ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Printer Port Dongle (XP SP2 refuses to work with it...)
    ... I know nothing about One CNC. ... What sort of parallel port key does it use? ... unrelated pieces of software that use a Sentinel parallel port driver from ... > dongle in the printer port. ...
    (microsoft.public.windowsxp.hardware)
  • Re: Parallel Port Service Failed to Start
    ... "JML" schreef in bericht ... > There is no Parallel port driver service listed in services that I could ...
    (microsoft.public.windows.server.sbs)