UniPRT SDK v2.0.0.0
 
载入中...
搜索中...
未找到
UsbComm.h
1//
2// UsbComm.h
3// TSCPrinters SDK
4//
5// Created by Realbuber on 2024/3/12.
6//
7
8
9
10#import <Foundation/Foundation.h>
11#import <IOKit/usb/IOUSBLib.h>
12#import <UniPRT/UsbInterfaceInfo.h>
13#import <UniPRT/AComm.h>
14
29@interface UsbComm: AComm
30
31@property (nonatomic, strong, readonly) NSMutableArray<UsbInterfaceInfo *> *discoveredInterfaces;
32@property (readonly, nonatomic) NSMutableDictionary *deviceList;
33@property (nonatomic, readonly) UsbInterfaceInfo *matchedInterfaces;
34
36@property (nonatomic, readonly) BOOL shouldStopReadLoop;
38
59- (instancetype)initWithVendorId:(NSString *)vendorId productId:(NSString *)productId;
60
69- (void)open;
70
79- (void)close;
80
95- (void)write:(NSData *)text;
96
111- (NSData*)read;
112
139- (NSData*)writeAndWaitForResponse:(NSData *)text
140 responseStartTimeOut:(NSTimeInterval)responseStartTimeOut
141 responseEndTimeOut:(NSTimeInterval)responseEndTimeOut
142 completionToken:(NSString *)completionToken;
143
144- (NSData*)writeAndWaitForResponseJson:(NSData *)text
145 responseStartTimeOut:(NSTimeInterval)responseStartTimeOut
146 responseEndTimeOut:(NSTimeInterval)responseEndTimeOut
147 completionToken:(NSString *)completionToken;
148
158
168
169@end
170
一个用于通信接口的基类,符合 IComm 协议。
定义 AComm.h:29
实现USB特定通信并继承AComm类的类。
定义 UsbComm.h:30
void stopListenRead()
停止从设备的异步读取。
UsbInterfaceInfo * matchedInterfaces
定义 UsbComm.h:33
NSData * read()
从设备读取数据。
void open()
打开设备连接。
NSMutableArray< UsbInterfaceInfo * > * discoveredInterfaces
定义 UsbComm.h:31
void close()
关闭设备连接。
NSMutableDictionary * deviceList
定义 UsbComm.h:32
void asyncListenRead()
异步监听并读取设备数据。