【发布时间】:2017-03-11 12:11:53
【问题描述】:
我刚收到带有打印机和现金抽屉的 mPOP 设备,我想尝试编写一个简单的应用程序来打开现金抽屉并在打开时写入日志,并在关闭时再次写入日志。我找不到任何简单的文档如何做到这一点。
有人可以帮忙用最少的代码 sn-p 打开钱箱以及如何检测它是打开还是关闭?
【问题讨论】:
标签: objective-c sdk
我刚收到带有打印机和现金抽屉的 mPOP 设备,我想尝试编写一个简单的应用程序来打开现金抽屉并在打开时写入日志,并在关闭时再次写入日志。我找不到任何简单的文档如何做到这一点。
有人可以帮忙用最少的代码 sn-p 打开钱箱以及如何检测它是打开还是关闭?
【问题讨论】:
标签: objective-c sdk
驱动器抽屉命令是ESC * r D [0|1|2|3] null,您可以在命令规范手册中找到它。编程文档可以在文档StarIO_POSPrinter_iOS_SDK.pdf 中找到。这两个文档都可以在Star Micronics Developers Section 中找到。以下sn-p摘自第二本手册。
sn-p 的第 1 行 command[] 数组中的字节 #5 定义应该激活哪个驱动器,可能是 0x00(无)、0x01(驱动器 1)、0x02(驱动器 2 ) 和0x03(两个驱动器)。
这是我在未经测试的情况下得到的,但也许你会从那里找到自己的路。
unsigned char command[] = {0x1B, 0x2A, 0x72, 0x44, 0x01, 0x00};
uint bytesWritten = 0;
StarPrinterStatus_2 starPrinterStatus;
SMPort *port = nil;
@try
{
port = [SMPort getPort:@"BT:" :@"" :10000];
//Start checking the completion of printing
[port beginCheckedBlock:&starPrinterStatus :2];
if (starPrinterStatus.offline == SM_TRUE)
{
//There was an error writing to the port
}
while (bytesWritten < sizeof (command)) {
bytesWritten += [port writePort: command : bytesWritten : sizeof (command) - bytesWritten];
}
//End checking the completion of printing
[port endCheckedBlock:&starPrinterStatus :2];
if (starPrinterStatus.offline == SM_TRUE)
{
//There was an error writing to the port
}
}
@catch (PortException)
{
//There was an error writing to the port
}
@finally
{
[SMPort releasePort:port];
}
【讨论】: