hi,大家好,我想在win2k下访问我的并口,怎么实现,请给予指教!

dycdyc123 2003-08-02 11:16:05
hi,大家好,我想在win2k下访问我的并口,怎么实现,请给予指教!

win98下可以!

请高手们给一个思路!!
...全文
30 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaohedou 2003-08-15
  • 打赏
  • 举报
回复
TO dycdyc123(重出江湖) :kingbug 原来是你,前两天我还当是谁。这个帖子我好几天没看了,今天看揭帖了,所以看看。以后多交流吧。

to dycdyc123(重出江湖) :我不知道你仔细看了没有!?你摘录得说明里写得很清楚啊。

你的问题:
“用winio以后,怎么还用_outp(0x378,outcommand),_inp(0x378)?读写端口需要用winio的GetPortVal SetPortVal来读写,”
你得答案:
Note: Under Windows 98/ME, an application must use the GetPortVal function to read values from an I/O port. Under Windows NT/2000/XP, it is possible to use the _inp/_inpw/_inpd functions instead of using GetPortVal, provided that the InitializeWinIo function has been called beforehand.

看见了!在Windows NT/2000/XP下可以用_inp/_inpw/_inpd 代替GetPortVal等.实际上最终的代码难道不是_inp/_outp吗?
dycdyc123 2003-08-08
  • 打赏
  • 举报
回复
AthlonxpX86(一滴水) : 感谢!

你怎么写的?

能给分代码 给我吗?

上面各位,如果要分的话,我可以给,7000多分!(呵呵,如果不是要分,那我太小人了 打自己嘴巴 :))
dycdyc123 2003-08-08
  • 打赏
  • 举报
回复
xiaohedou(小黑豆) :

感谢!!!!

QQ 我加了!! kingbug!!!! it is me!

AthlonxpX86 2003-08-07
  • 打赏
  • 举报
回复
在nt/2000/xp下面用winio或者自己写驱动,用winio简单一些,你可以看看说明

to xiaohedou(小黑豆):不知道你用过winio没有,用winio以后,怎么还用_outp(0x378,outcommand),_inp(0x378)?读写端口需要用winio的GetPortVal SetPortVal来读写,下面是winio提供的这两个函数说明
GetPortVal
This function reads a BYTE/WORD/DWORD value from an I/O port.

bool _stdcall GetPortVal(
WORD wPortAddr,
PDWORD pdwPortVal,
BYTE bSize
);
Parameters
wPortAddr
[in] I/O port address

pdwPortVal
[out] Pointer to a DWORD variable that receives the value obtained from the port.

bSize
[in] Number of bytes to read.
Can be 1 (BYTE), 2 (WORD) or 4 (DWORD).
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The GetPortVal function reads a byte, a word or a double word from the specified I/O port.

Note: Under Windows 98/ME, an application must use the GetPortVal function to read values from an I/O port. Under Windows NT/2000/XP, it is possible to use the _inp/_inpw/_inpd functions instead of using GetPortVal, provided that the InitializeWinIo function has been called beforehand.




SetPortVal
This function writes a BYTE/WORD/DWORD value to an I/O port.

bool _stdcall SetPortVal(
WORD wPortAddr,
DWORD dwPortVal,
BYTE bSize
);
Parameters
wPortAddr
[in] I/O port address

dwPortVal
[in] Value to be written to the port

bSize
[in] Number of bytes to write.
Can be 1 (BYTE), 2 (WORD) or 4 (DWORD).
Return Values
If the function succeeds, the return value is true. Otherwise, the function returns false.
Remarks
The SetPortVal function writes a byte, a word or a double word to the specified I/O port.

Note: Under Windows 98/ME, an application must use the SetPortVal function to write values to an I/O port. Under Windows NT/2000/XP, it is possible to use the _outp/_outpw/_outpd functions instead of using SetPortVal, provided that the InitializeWinIo function has been called beforehand.


如果想自己写驱动来控制并口,我写过,给你源代码,不过我的驱动也只完成了winio的部分功能,代码包中里面包含winio,
http://www.csdn.net/cnshare/soft/16/16791.shtm

如果读写端口解决了,就需要了解一下并口协议,下面有全部的详细的并口协议SPP EPP ECP
http://www.beyondlogic.org/
xiaohedou 2003-08-06
  • 打赏
  • 举报
回复
关于计算机的并行打印适配器地址:
在CMOS里可以指定:0x278-0x27f(LPT1)和0x378-0x37f(LPT2)。默认端口地址是0x378-0x37F。实际应用到的地址主要有三个:
数据输出端口:378H
状态输出端口:379H
控制输出端口:37AH
关于三个端口的使用我在前面已经讲了,大家看看。
xiaohedou 2003-08-06
  • 打赏
  • 举报
回复
对于大家的议论:
WinIO是把_outp/_inp之类的解析了映射到物理地址,我用它作了一些并口(包括自己研发的接口板地址ox300-0x307);还作过一个win2k下的发声程序,效果不错。向大家推荐是它又源文件,可功研究。


dycdyc123 (重出江湖) :我给你找了一个类,一下是片断:其它的qq联系。

void CParallelPort::Open(int nPort)
{
//Call Close just in case we already have the port open
Close();

m_nPortIndex = nPort - 1;
if (m_nPortIndex < sm_Ports.GetSize())
{
//Cache the base address of the port for performance reasons
m_nBaseAddress = sm_Ports.ElementAt(m_nPortIndex).m_nBaseAddress;

//Call CreateFile to open up the parallel port. This prevents other apps
//causing problems when we do the Port IO directly.
CString sPort;
sPort.Format(_T("\\\\.\\LPT%d"), nPort);
m_hPort = CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (m_hPort == INVALID_HANDLE_VALUE)
{
TRACE(_T("Failed to open parallel port, LPT%d\n"), nPort);
Close();
AfxThrowParallelException();
}
}
else
{
TRACE(_T("Could not find the parallel port, LPT%d\n"), nPort);
Close();
AfxThrowParallelException(ERROR_FILE_NOT_FOUND);
}
}
lmpity 2003-08-06
  • 打赏
  • 举报
回复
这些在2000下都不行
Leo 2003-08-05
  • 打赏
  • 举报
回复
用createfile打开并口,再用witefile()和readfile()发送和接收数据
liulin 2003-08-05
  • 打赏
  • 举报
回复
WRITECHAR,READCHAR。
地址0x378吧,好像
dycdyc123 2003-08-05
  • 打赏
  • 举报
回复
Only use the WinIo ??

xiaohedou 2003-08-05
  • 打赏
  • 举报
回复
输出一个字符串,假设字符在AL中,调用这个子程序!

SUBPRINT PORC NEAR
PUSH AX
PUSH DX
MOV DX,378H
OUT DX,AL
MOV DX,379H
SUBWAIT:
IN AL,DX
TEST AL,10000000B
JE SUBWAIT
MOV AL,00001101B
MOV DX,37AH
OUT DX,AL
MOV AL,00001100B
OUT DX,AL
POP DX
POP AL
RET
SUBPRINT ENDP
garryfox 2003-08-04
  • 打赏
  • 举报
回复
up
xiaohedou 2003-08-04
  • 打赏
  • 举报
回复
可以先下一个WinIO在www.internals.com,这是个著名的端口操作软件。含源程序,可以仔细研究!下面就可以对并口用_outp(0x378,outcommand),_inp(0x378)等操作!
dycdyc123 2003-08-02
  • 打赏
  • 举报
回复
高手帮帮呀!

21,597

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 驱动开发/核心开发
社区管理员
  • 驱动开发/核心开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧