UniPRT SDK v2.0.0.0
 
Loading...
Searching...
No Matches
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
A base class for communication interfaces, conforming to the IComm protocol.
Definition AComm.h:29
Class that implements the USB specific communication and extends the AComm class.
Definition UsbComm.h:30
void stopListenRead()
Stops asynchronous reading from the device.
UsbInterfaceInfo * matchedInterfaces
Definition UsbComm.h:33
NSData * read()
Reads data from the device.
void open()
Opens the connection to the device.
NSMutableArray< UsbInterfaceInfo * > * discoveredInterfaces
Definition UsbComm.h:31
void close()
Closes the connection to the device.
NSMutableDictionary * deviceList
Definition UsbComm.h:32
void asyncListenRead()
Asynchronously listens for and reads data from the device.