vb.net 打开连接到计算机 rj11 端口的钱箱

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13293768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 11:04:45  来源:igfitidea点击:

Open cash drawer connected to a computer's rj11 port

vb.netpoint-of-sale

提问by Rafael Osuna Dominguez

I've a software made in VB.Net which opened a cash drawer connected to a receipt printer. A few days before came up a problem, the model of printer has changed and i have to connect the cash drawer to a rj11 port in the computer. I know nothing about this port, this is not a COM port neither is a modem.

我有一个用 VB.Net 制作的软件,它打开了一个连接到收据打印机的现金抽屉。前几天出现问题,打印机型号变了,我必须将钱箱连接到计算机的rj11端口。我对这个端口一无所知,这不是 COM 端口,也不是调制解调器。

Has anybody faced this problem before?

有没有人遇到过这个问题?

Thanks in advance

提前致谢

回答by Re0sless

I don't have a lot of experience with VB.net, but I have communicated with these ports in Delphi so here is what I know.

我对 VB.net 没有很多经验,但我已经与 Delphi 中的这些端口进行了交流,所以这就是我所知道的。

The way these port usually work is they have fixed IRQ locations, these are detailed in the manufactures manual

这些端口通常工作的方式是它们有固定的 IRQ 位置,这些在制造商手册中有详细说明

The process for opening the cash draw is as follows

开通提现流程如下

  1. Get the memory (IRQ) for the port (this should be detailed in the manufacturer's manual)
  2. Get the current 8-bit (short) value from the port (so we don't mess with there settings)
  3. Flipping the relevant bit on or off (1 or 0) using OR to turn on, and AND to turn off to open the draw
  4. Waiting a second for the draw to open (else the bit will be flipped back before the draw has time to respond)
  5. Flipping the relevant bit on or off (1 or 0) using OR to turn on, and AND to turn off to re-engage the locking pin on the draw (else the draw will just spring open again when they close it)*

    • Note: That you don't just set the value back to the value you got in the first place because if the program crashed before flipping it back to locked you cant lock the draw without a reboot, so using an AND or OR on the original value will ensure that the 1 is a 0 or the other way round.
  1. 获取端口的内存(IRQ)(这应该在制造商手册中详细说明)
  2. 从端口获取当前的 8 位(短)值(这样我们就不会弄乱那里的设置)
  3. 使用 OR 打开或关闭相关位(1 或 0)打开,AND 关闭以打开抽奖
  4. 等待一秒钟以打开平局(否则该位将在平局有时间响应之前翻转回来)
  5. 使用 OR 打开或关闭相关位(1 或 0),然后关闭以重新接合抽头上的锁定销(否则抽头在关闭时会再次弹开)*

    • 注意:您不只是将值设置回您最初获得的值,因为如果程序在将其翻转回锁定之前崩溃,您无法在不重新启动的情况下锁定绘图,因此在原始值上使用 AND 或 OR value 将确保 1 为 0 或相反。

The biggest problem is that accessing these ports in Windows is a bit of a pain, as most of the commands are now restricted (i.e. classed as privileged instructions) there are 3rd party DLLs out there that can by pass this however (such as Inpout32.dll) - Although VB.net may not have this restriction.

最大的问题是在 Windows 中访问这些端口有点麻烦,因为现在大多数命令都受到限制(即被归类为特权指令),但是有 3rd 方 DLL 可以绕过它(例如Inpout32.dll)。 dll) - 虽然 VB.net 可能没有这个限制。



From the Tysso 5700 User Manual

来自 Tysso 5700 用户手册

Cash Drawer Controller Register
Register Location: I/O port 280h
Size: 8 bit
Bit 0~3, 5~7: Reserved
Bit 4: Cash Drawer “DIO OUTPUT”, pin output control. 1: Open the Cash Drawer 0: Close the Cash Drawer

钱箱控制器寄存器
寄存器地址:I/O 口 280h
大小:8 位
Bit 0~3, 5~7:保留
Bit 4:钱箱“DIO OUTPUT”,引脚输出控制。1:打开钱箱 0:关闭钱箱