3.1. Port¶
Class to communicate with a printer.
Property
Name
Contents
Set the timeout value for hold print control.
Constructor
Name
Contents
Creates the Port object.
Method
Name
Contents
Opens a port for communicating with the printer.
Closes a port for communicating with the printer.
Write data to the printer.
Read data from the printer.
Get printer status.
Gets printer online status.
Starts to check completion of printing.
Terminates to check completion of printing.
Gets printer model name and firmware version.
3.1.1. HoldPrintTimeout¶
added in version 1.7.0
Timeout value for hold print control. [unit: ms]
Declaration
public int HoldPrintTimeout { get; set; }
3.1.2. Port¶
Creates the Port object.
Declaration
public Port() public Port(Int32 timeout)
Parameter
Name Contents Type timeout Sets Default timeout value.Default timeout value is 30000mS if the argument is omitted.Int32 Return value
Contents Type Port object Port
3.1.3. ConnectAsync¶
Opens a port for communicating with the printer.
Declaration
public IAsyncAction ConnectAsync(string portName, string portSettings) public IAsyncAction ConnectAsync(ProductInformation info, string portSettings)
Parameter
Name Contents Type portName The printer port name string info A ref:StarIO_PortInfo object obtained by the FindAllAsync method ProductInformation portSettings Specifies connection setting information. string Return value
None
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred StarResultCode.ErrorInUse Connection was refused by the printer (another host is connected or other reason)
- portName Parameter
Interface |
portName |
Contents |
Example |
Library version |
---|---|---|---|---|
Bluetooth | BT: | Communicates with the first Star printer found.
Pair only one Star printer.
|
"BT:" | 1.1.0+ |
BT:Device Name | To specify the Bluetooth device name |
"BT:Star Micronics" | ||
BT:MAC Address | To specify the MAC address |
"BT:00:12:F3:1E:2B:72" | ||
Ethernet/Wireless LAN | TCP:IP Address | To specify the IP address |
"TCP:192.168.1.100" | 1.1.0+ |
portSettings Parameter
The portSettings string is specified using the format shown below.
The identifier that should be used with that model + option specification strings delimited by ‘;’.
The identifier that should be used with each model is as shown below.
Model
Emulation
Identifier
mC-Print2 StarPRNT "" mC-Print3 StarPRNT "" mPOP StarPRNT "" FVP10 StarLine "" TSP100IV StarPRNT "" TSP100IIIW StarGraphic "" TSP100IIIBI StarGraphic "" TSP100LAN StarGraphic "" TSP650II StarLine "" TSP650IISK StarLine "" TSP700II StarLine "" TSP800II StarLine "" SM-S210i StarPRNT "Portable" EscPosMobile "Portable;escpos" or "mini" SM-S220i StarPRNT "Portable" EscPosMobile "Portable;escpos" or "mini" SM-S230i StarPRNT "Portable" EscPosMobile "Portable;escpos" or "mini" SM-T300i/T300 StarPRNT "Portable" EscPosMobile "Portable;escpos" or "mini" SM-T400i StarPRNT "Portable" EscPosMobile "Portable;escpos" or "mini" BSC10 EscPos "escpos" SM-L200 StarPRNT "Portable" SM-L300 StarPRNT "Portable" SP700 StarDotImpact "" The option specification strings are shown below.
Interface
Option type
Contents
Example
Library version
Bluetooth d[value]
Data timeout function timeout value setting.
If the d option is not specified with a model that supports the data timeout function, the data timeout function is enabled and the timeout value is set to 3 seconds.
The method for specifying the timeout time is the following.
- If a value from 1 to 255 was specified for [value]: Time that was specified for [value]
- If 0 was specified for [value] : Data timeout function is ignored
- Other than the above: 3 seconds
"d10" 1.1.0+ l[value](lower case “L”)
Connection retry will be performed.
The method for specifying the retry time is the following.
- If a value will not be specified (“l” only) : Timeout time specified by the getPort
- If a value from 0 to 300000 was specified for [value]: Time that was specified for [value] (units: milliseconds).
- If a value of 300001 or more was specified for [value] : Timeout time specified by the getPort
- Other than the above: Retry is not performed.
"l10000" 1.1.0+ Ethernet/Wireless LAN l[value](lower case “L”)
Connection retry will be performed when the target printer is in use by another host.
The method for specifying the retry time is the following.
- If a value will not be specified (“l” only) : Timeout time specified by the getPort
- If a value from 0 to 300000 was specified for [value]: Time that was specified for [value] (units: milliseconds).
- If a value of 300001 or more was specified for [value] : Timeout time specified by the getPort
- Other than the above: Retry is not performed.
"l10000" 1.7.0+ Data timeout function
The data timeout function is a function which ignores the remaining print data when data was not sent to the printer within the specified length of time during printing.This function prevents corruption of the next print contents after the Bluetooth connection was disconnected during data sending.For usable models, refer to below.Model Firmware version mC-Print2 1.0+ mC-Print3 1.0+ mPOP 1.0+ FVP10 2.0+ TSP100IIIBI 1.0+ TSP650II 2.0+ TSP650IISK 1.0+ TSP700II 5.0+ TSP800II 2.0+ Example of portSettings
Printer connection environment portSettings Uses TSP650II as the default setting. “” Uses mC-Print3 with retry enabled by Ethernet interface. “;l10000” Uses SM-L200 as the default setting “Portable” If data is not sent for 10 seconds during printing withTSP650II, it operates the data canceling function. “;d10”
- The using Statement, ConnectAsync method may fail if you run it just after running using Statement, ConnectAsync method.You must run the using Statement, ConnectAsync method after 1 sec from using Statement, ConnectAsync method.
3.1.4. Close¶
Closes a port for communicating with the printer.
Declaration
Public void Close()
Parameter
None
Return value
None
3.1.5. WriteAsync¶
Write data to the printer.
Declaration
public IAsyncOperation<uint> WriteAsync(IBuffer buffer); public IAsyncOperation<uint> WriteAsync(IBuffer buffer, Int32 timeout);
Parameter
Name Contents Type buffer Buffer in which data is stored IBuffer timeout Timeout value for writing dataDefault timeout value is set by Port constructor, if the argument is omitted.Int32 Return value
Contents Type Written data size uint
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred.
3.1.6. ReadAsync¶
Read data from the printer. Please use it only when it is necessary to read Raw byte from the printer.
Declaration
public IAsyncOperation<IBuffer> ReadAsync(); public IAsyncOperation<IBuffer> ReadAsync(Int32 timeout);
Parameter
Name Contents Type timeout Timeout value of data read Int32 Return value
Contents Type IBuffer object read from the receiving stream IBuffer
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred.
3.1.7. GetParsedStatusAsync¶
Get printer status.
Declaration
public IAsyncOperation<Status> GetParsedStatusAsync(); public IAsyncOperation<Status> GetParsedStatusAsync(Int32 timeout);
Parameter
Name Contents Type timeout Timeout value for getting status Int32 Return value
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred.
3.1.8. GetOnlineStatusAsync¶
Gets printer online status.
Declaration
public IAsyncOperation<bool> GetOnlineStatusAsync(); public IAsyncOperation<bool> GetOnlineStatusAsync(Int32 timeout);
Parameter
Name Contents Type timeout Timeout value for getting online status Int32 Return value
Contents Type Online status of the printertrue … Onlinefalse … Offlinebool
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred.
3.1.9. BeginCheckedBlockAsync¶
This method is used in combination with EndCheckedBlockAsync and checks the completion of printing.
To check if the whole data is completely printed, you need to run this method just before sending print data and EndCheckedBlockAsync just after sending print data.
When the control of hold print control is enabled, this method blocks until the paper is removed, and returns control to the application when it is removed. If paper is not removed within the timeout specified by the HoldPrintTimeout, the error is occured.
Declaration
public IAsyncOperation<Status> BeginCheckedBlockAsync(); public IAsyncOperation<Status> BeginCheckedBlockAsync(Int32 timeout);
Parameter
Name Contents Type timeout Timeout value for starting to check completion of printing Int32 Return value
Error code
Value
Contents
Library version
StarResultCode.ErrorPaperPresent
Paper was not removed within the timeout.
1.7.0+
StarResultCode.ErrorFailed
Some kind of error occurred.
1.1.0+
Examples
Refer to StarIOPort_PrintingFlow about the procedure of the print end monitoring process by BeginCheckedBlockAsync / EndCheckedBlockAsync.
3.1.10. EndCheckedBlockAsync¶
This method is used together with the BeginCheckedBlockAsync method as a pair.
This method monitors printer status and when the transferred data is printed completely or when the printer status is offline during printing or when occurs the timeout specified by the EndCheckedBlockAsync , it returns control to the application.
Declaration
public IAsyncOperation<Status> EndCheckedBlockAsync(); public IAsyncOperation<Status> EndCheckedBlockAsync(Int32 timeout);
Parameter
Name Contents Type timeout Timeout Value for terminating a check of completion of printing Int32 Return value
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred. Examples
Refer to StarIOPort_PrintingFlow about the procedure of the print end monitoring process by BeginCheckedBlockAsync / EndCheckedBlockAsync.
3.1.11. GetFirmwareInformationAsync¶
Gets printer model name and firmware version.
Declaration
public IAsyncOperation<FirmwareInformation> GetFirmwareInformationAsync(); public IAsyncOperation<FirmwareInformation> GetFirmwareInformationAsync(Int32 timeout);
Parameter
Name Contents Type timeout Timeout value for get information of printer status Int32 Return value
Contents Type FirmwareInformation object FirmwareInformation
Error code
Value Contents StarResultCode.ErrorFailed Some kind of error occurred.