【问题标题】:How to open Star Micronics mPOP cash drawer using code如何使用代码打开 Star Micronics mPOP 现金抽屉
【发布时间】:2017-03-11 12:11:53
【问题描述】:

我刚收到带有打印机和现金抽屉的 mPOP 设备,我想尝试编写一个简单的应用程序来打开现金抽屉并在打开时写入日志,并在关闭时再次写入日志。我找不到任何简单的文档如何做到这一点。

有人可以帮忙用最少的代码 sn-p 打开钱箱以及如何检测它是打开还是关闭?

【问题讨论】:

    标签: objective-c sdk


    【解决方案1】:

    驱动器抽屉命令是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];
    }
    

    【讨论】:

    • 文档远不清楚我需要包含什么才能访问这些功能,我已经将框架等添加到我的项目中,但是我在我的 .h 文件中#import 什么文件或框架访问这些功能,如 SMPort ?
    • 我在有和没有路径的情况下都试过了,但仍然没有运气,#import
    • 从starmicronics.com 下载IOS_SDK,它是作为应用模板构建的。使用 XCode 打开 IOS_SDK.xcodeproj。编辑文件 IOS_SDKViewController.m ,这是应用程序的起点。所有必需的标题等都应该准备好供您使用。
    • 我已经有一个现有的应用程序我无法将我的应用程序 i 移动到 sdk 模板,很抱歉我对此感到非常困惑,我希望它可以像我集成到我的任何其他库一样工作像 zbar、iZettle 等应用程序,但这真的让我头晕目眩,我想将框架添加到我自己的应用程序中并在我的应用程序中获取可用的功能
    • 我没有打印机,所以我无法提供更多帮助。我将从应用程序模板开始并使其工作,然后删除不需要的所有内容。最后,您将拥有一个可以工作的最小代码示例,并且将更容易添加到您现有的项目中。祝你好运哥们...
    猜你喜欢
    • 2016-12-26
    • 2011-04-19
    • 1970-01-01
    • 2021-01-06
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 2016-09-24
    • 2018-01-05
    相关资源
    最近更新 更多