Windows 上的 LPT 控制
我正在进行新项目,该项目应该使用微控制器。最简单的编程方法是使用并行端口。但是,有几件事我希望你能帮助我。哦,首选语言是 C 和 Windows 平台。
因此,我研究了一点LPT端口和Windows,从我学到的最重要的是:由于基于Windows NT的系统,你不能使用指令直接操作端口。应该是这样,因为现在程序运行在不同的特权模式下,不支持 outport()
函数使用的指令类型。
但此时,我不明白一些事情。首先,我认为 Windows 实际上从第一个保护模式版本开始就使用了特权级别,但这是错误的假设。
但更重要的是,我认为 Windows 已经包含了几乎所有硬件通信的功能。我的意思是,现在你在 Windows 中执行的任何操作,都只需调用进一步调用内核服务的 Windows 函数。我假设 outport()
不使用任何 Windows 函数,而只是进行通信本身,现在这是禁止的。但令我震惊的是,现代 Windows 系统中没有控制并行端口的系统功能。至少我读到的是这样的。
但即使我可以控制并行端口,我的第二个问题也来了。 为了对控制器进行编程,我需要遵循特殊的协议,尤其是时序。但由于Windows是多任务的,我担心如果Scheduler切换到另一个应用程序会怎样,因此何时是切换LPT信号的合适时间,我的程序将无法运行。
哦,顺便说一句,我知道我可以使用任何第 3 方应用程序,但我只是想自己能够做到这一点,或者至少在我使用某些第 3 方应用程序之前,我想知道它是如何工作的。是的,您可以通过带有一些电阻的并行端口对一些微控制器进行编程,我确信这一点。
谢谢。
I am into new project, which should use microcontroller. The easiest way to program it is using parallel port. But, there are few things I hope you can help me with. Oh, and the preferred language is C and platform Windows.
So, I studied LPT ports and Windows a bit, and from what I learned the most important is: Since Windows NT based systems, you cannot use instructions for direct port manipulation. This should be, because now programs are run in different privilege mode, which doesn't support the kind of instructions that are used by outport()
function.
But at this point, I don´t understand a few things. First, I thought that Windows actually used privilege levels since first protected mode version, but that's the wrong assumption.
But more importantly, I thought that Windows has included functions for just about any hardware communication. I mean, anything you do in Windows these days, you just call windows functions which further call kernel services. I assumed that outport()
doesn´t use any Windows function, and just makes the communication itself, which is prohibited now. But I am literally shocked that there is no system function to control parallel ports in modern Windows systems. At least that's what I read.
But even if I could get the control of parallel port, there comes my second problem.
For programming the controller, I need to follow special protocol, especially timing. But since Windows is multitasked, I worry about what if Scheduler switches to another app, and therefore when is the right time to switch signals on LPT, my program just will not be able to run.
Oh, by the way, I know I could use any 3rd-party apps, but I just like to be able to do it myself, or at least before I use some 3rd-party app, I want to know how it works. And yes, you can program some microcontrollers just by parallel port with some resistors, I know this for sure.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 Windows,您需要安装一个 DLL,其中包含一个以提升的权限运行的驱动程序,以访问硬件端口。
您可以在以下位置找到这样的库:
http://logix4u。 net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html
还有一些示例代码的链接。
我不知道你使用的是哪个 uController,但我过去对它们进行过编程,并且从未遇到过时序问题,至少对于编程来说是这样。编程协议通常足够强大,可以处理多任务引起的抖动。只要保持时钟边缘和信号边缘分开,就应该可以正常工作。
For windows you need to install a DLL which contains a driver to run at elevated privileges to get access to the HW ports.
You can find such a library at :
http://logix4u.net/Legacy_Ports/Parallel_Port/Inpout32.dll_for_Windows_98/2000/NT/XP.html
There are also some links to sample code.
I do not know which uController you are using, but I programmed in the past a variety of them and never had issues with timings, well for programming at least. The programming protocols are usually robust enough to deal with the jitter caused by multitasking. Just keep your clock edges and signa edges well separated and it should go fine.