Documentation
¶
Index ¶
- Constants
- Variables
- func Parse(data []byte) (out []byte, err error)
- type ClearAndRecoverCmd
- type Cmd
- type CmdEvent
- type CmdRes
- type ConnectionEvent
- type Controller
- func (c *Controller) ClearAndRecover() error
- func (c *Controller) Close()
- func (c *Controller) DisablePulseLevel() error
- func (c *Controller) DrawerStatus() (*DrawerStatus, error)
- func (c *Controller) EnablePulseLevel() error
- func (c *Controller) ErrorStatus() (*ErrorStatus, error)
- func (c *Controller) Firmware() (Info, error)
- func (c *Controller) IsClosed() bool
- func (c *Controller) Maker() (Info, error)
- func (c *Controller) Model() (Info, error)
- func (c *Controller) ModelID() (*ModelID, error)
- func (c *Controller) OfflineStatus() (*OfflineStatus, error)
- func (c *Controller) PaperStatus() (*PaperStatus, error)
- func (c *Controller) PressFeedButton() error
- func (c *Controller) PrinterStatus() (*PrinterStatus, error)
- func (c *Controller) PulseDrawerPin2(tOn, tOff byte) error
- func (c *Controller) PulseDrawerPin2Level1() error
- func (c *Controller) PulseDrawerPin2Level2() error
- func (c *Controller) PulseDrawerPin2Level3() error
- func (c *Controller) PulseDrawerPin2Level4() error
- func (c *Controller) PulseDrawerPin2Level5() error
- func (c *Controller) PulseDrawerPin2Level6() error
- func (c *Controller) PulseDrawerPin2Level7() error
- func (c *Controller) PulseDrawerPin2Level8() error
- func (c *Controller) PulseDrawerPin5(tOn, tOff byte) error
- func (c *Controller) PulseDrawerPin5Level1() error
- func (c *Controller) PulseDrawerPin5Level2() error
- func (c *Controller) PulseDrawerPin5Level3() error
- func (c *Controller) PulseDrawerPin5Level4() error
- func (c *Controller) PulseDrawerPin5Level5() error
- func (c *Controller) PulseDrawerPin5Level6() error
- func (c *Controller) PulseDrawerPin5Level7() error
- func (c *Controller) PulseDrawerPin5Level8() error
- func (c *Controller) Recover() error
- func (c *Controller) Reset() error
- func (c *Controller) RollStatus() (*RollStatus, error)
- func (c *Controller) Send(b []byte) error
- func (c *Controller) SerialNo() (Info, error)
- func (c *Controller) TypeID() (*TypeID, error)
- type ControllerConfig
- type Dev
- type DevConfig
- type DrawerEvent
- type DrawerStatus
- type ErrorStatus
- type Event
- type FeedButtonEvent
- type FileDev
- type FinishPrintEvent
- type FirmwareCmd
- type Info
- type InfoRes
- type MakerCmd
- type ModelCmd
- type ModelID
- type ModelIDCmd
- type ModelIDRes
- type OfflineStatus
- type PaperNearEndEvent
- type PaperStatus
- type Parity
- type ParseError
- type PressFeedButtonCmd
- type PrintCmd
- type PrinterStatus
- type PulseCmd
- type PulseLevelCmd
- type RawCmd
- type RecoverCmd
- type Res
- type RollStatus
- type Scanner
- type ScannerConfig
- type SerialConfig
- type SerialDev
- type SerialNoCmd
- type StartPrintEvent
- type State
- type StateEvent
- type TypeID
- type TypeIDCmd
- type TypeIDRes
Constants ¶
const ( Interval = time.Second / 2 ErrDelay = 5 * time.Second Timeout = time.Second Wait = 100 * time.Millisecond ReadTimeout = 50 * time.Millisecond WriteTimeout = 50 * time.Millisecond Baudrate = 9600 DataBits = 8 )
const ( NUL = 0 SOH = 1 STX = 2 ETX = 3 EOT = 4 ENQ = 5 ACK = 6 BEL = 7 BS = 8 HT = 9 LF = 10 VT = 11 FF = 12 CR = 13 SO = 14 SI = 15 DLE = 16 DC1 = 17 DC2 = 18 DC3 = 19 DC4 = 20 NAK = 21 SYN = 22 ETB = 23 CAN = 24 EM = 25 SUB = 26 ESC = 27 FS = 28 GS = 29 RS = 30 US = 31 SP = ' ' DQ = '"' SQ = '\'' DEL = 127 XON = DC1 XOFF = DC3 )
const ( MODEL_MASK = 0b1001_0000 MODEL_FIXED = 0b0000_0000 TYPE_MASK = 0b1001_0000 TYPE_FIXED = 0b0000_0000 TYPE_MULTI_BYTE = 0b0000_0001 TYPE_AUTOCUTTER = 0b0000_0010 TYPE_DISPLAY = 0b0000_0100 )
const ( NoParity = Parity(serial.NoParity) OddParity = Parity(serial.OddParity) EvenParity = Parity(serial.EvenParity) )
const ( PRN_MASK = 0b1001_0011 PRN_FIXED = 0b0001_0010 PRN_DRAWER = 0b0000_0100 PRN_OFFLINE = 0b0000_1000 PRN_RECOVERY = 0b0010_0000 PRN_FEED_BTN = 0b0100_0000 OFF_MASK = 0b1001_0011 OFF_FIXED = 0b0001_0010 OFF_COVER = 0b0000_0100 OFF_FED = 0b0000_1000 OFF_PAPER = 0b0010_0000 OFF_ERROR = 0b0100_0000 ERR_MASK = 0b1001_0011 ERR_FIXED = 0b0001_0010 ERR_RECOVER = 0b0000_0100 ERR_AUTOCUTTER = 0b0000_1000 ERR_UNRECOVER = 0b0010_0000 ERR_AUTO_RECOVER = 0b0100_0000 ROLL_MASK = 0b1001_0011 ROLL_FIXED = 0b0001_0010 ROLL_NEAR_END = 0b0000_1100 ROLL_NO_PAPER = 0b0110_0000 PAPER_MASK = 0b1001_0000 PAPER_FIXED = 0b0000_0000 PAPER_NEAR_END = 0b0000_0011 PAPER_END = 0b0000_1100 DRAWER_MASK = 0b1001_0000 DRAWER_FIXED = 0b0000_0000 DRAWER_PIN_3 = 0b0000_0001 )
const (
CHUNK = 40
)
const (
INFO_HEADER = '_'
)
Variables ¶
var ( ErrorLogFunc func(string, ...interface{}) InfoLogFunc func(string, ...interface{}) DebugLogFunc func(string, ...interface{}) )
var ( DisconnectErr = errors.New("Printer disconnected") PrintingInProgressErr = errors.New("Printing in progress") )
Functions ¶
Types ¶
type ClearAndRecoverCmd ¶
type ClearAndRecoverCmd struct{}
func (ClearAndRecoverCmd) String ¶
func (c ClearAndRecoverCmd) String() string
type ConnectionEvent ¶
func (ConnectionEvent) String ¶
func (e ConnectionEvent) String() string
type Controller ¶
type Controller struct {
Dev Dev
Config *ControllerConfig
// contains filtered or unexported fields
}
func (*Controller) ClearAndRecover ¶
func (c *Controller) ClearAndRecover() error
Recover from recoverable error after clearing the receive and print buffers in real-time.
func (*Controller) Close ¶
func (c *Controller) Close()
func (*Controller) DisablePulseLevel ¶
func (c *Controller) DisablePulseLevel() error
Disable both real-time pulse command (DLE DC4 1 or 2).
func (*Controller) DrawerStatus ¶
func (c *Controller) DrawerStatus() (*DrawerStatus, error)
func (*Controller) EnablePulseLevel ¶
func (c *Controller) EnablePulseLevel() error
Enable both real-time pulse command (DLE DC4 1 or 2).
func (*Controller) ErrorStatus ¶
func (c *Controller) ErrorStatus() (*ErrorStatus, error)
Get real-time error status.
func (*Controller) Firmware ¶
func (c *Controller) Firmware() (Info, error)
func (*Controller) IsClosed ¶
func (c *Controller) IsClosed() bool
func (*Controller) Maker ¶
func (c *Controller) Maker() (Info, error)
func (*Controller) Model ¶
func (c *Controller) Model() (Info, error)
func (*Controller) ModelID ¶
func (c *Controller) ModelID() (*ModelID, error)
func (*Controller) OfflineStatus ¶
func (c *Controller) OfflineStatus() (*OfflineStatus, error)
Get real-time offline status.
func (*Controller) PaperStatus ¶
func (c *Controller) PaperStatus() (*PaperStatus, error)
func (*Controller) PressFeedButton ¶
func (c *Controller) PressFeedButton() error
Press Feed Button in real-time. Note: support depend on printer type.
func (*Controller) PrinterStatus ¶
func (c *Controller) PrinterStatus() (*PrinterStatus, error)
Get real-time printer status.
func (*Controller) PulseDrawerPin2 ¶
func (c *Controller) PulseDrawerPin2(tOn, tOff byte) error
Pulse the pin 2 of drawer connector for (tOn * 2ms) ON and (tOff * 2ms) OFF. Most printer force tOff >= tOn and some has minimal tOn and/or tOff. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level1 ¶
func (c *Controller) PulseDrawerPin2Level1() error
Pulse the pin 2 of drawer connector for 100ms ON and 100ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level2 ¶
func (c *Controller) PulseDrawerPin2Level2() error
Pulse the pin 2 of drawer connector for 200ms ON and 200ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level3 ¶
func (c *Controller) PulseDrawerPin2Level3() error
Pulse the pin 2 of drawer connector for 300ms ON and 300ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level4 ¶
func (c *Controller) PulseDrawerPin2Level4() error
Pulse the pin 2 of drawer connector for 400ms ON and 400ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level5 ¶
func (c *Controller) PulseDrawerPin2Level5() error
Pulse the pin 2 of drawer connector for 500ms ON and 500ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level6 ¶
func (c *Controller) PulseDrawerPin2Level6() error
Pulse the pin 2 of drawer connector for 600ms ON and 600ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level7 ¶
func (c *Controller) PulseDrawerPin2Level7() error
Pulse the pin 2 of drawer connector for 700ms ON and 700ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin2Level8 ¶
func (c *Controller) PulseDrawerPin2Level8() error
Pulse the pin 2 of drawer connector for 800ms ON and 800ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5 ¶
func (c *Controller) PulseDrawerPin5(tOn, tOff byte) error
Pulse the pin 5 of drawer connector for (tOn * 2ms) ON and (tOff * 2ms) OFF. Most printer force tOff >= tOn and some has minimal tOn and/or tOff. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level1 ¶
func (c *Controller) PulseDrawerPin5Level1() error
Pulse the pin 5 of drawer connector for 100ms ON and 100ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level2 ¶
func (c *Controller) PulseDrawerPin5Level2() error
Pulse the pin 5 of drawer connector for 200ms ON and 200ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level3 ¶
func (c *Controller) PulseDrawerPin5Level3() error
Pulse the pin 5 of drawer connector for 300ms ON and 300ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level4 ¶
func (c *Controller) PulseDrawerPin5Level4() error
Pulse the pin 5 of drawer connector for 400ms ON and 400ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level5 ¶
func (c *Controller) PulseDrawerPin5Level5() error
Pulse the pin 5 of drawer connector for 500ms ON and 500ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level6 ¶
func (c *Controller) PulseDrawerPin5Level6() error
Pulse the pin 5 of drawer connector for 600ms ON and 600ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level7 ¶
func (c *Controller) PulseDrawerPin5Level7() error
Pulse the pin 5 of drawer connector for 700ms ON and 700ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) PulseDrawerPin5Level8 ¶
func (c *Controller) PulseDrawerPin5Level8() error
Pulse the pin 5 of drawer connector for 800ms ON and 800ms OFF in real-time. From Epson docs it's not possible to pulse both pin at the same time.
func (*Controller) Recover ¶
func (c *Controller) Recover() error
Recover from recoverable error and restart printing from the line where the error occured in real-time. Note: support depend on printer type.
func (*Controller) Reset ¶
func (c *Controller) Reset() error
func (*Controller) RollStatus ¶
func (c *Controller) RollStatus() (*RollStatus, error)
Get real-time paper roll status.
func (*Controller) Send ¶
func (c *Controller) Send(b []byte) error
func (*Controller) SerialNo ¶
func (c *Controller) SerialNo() (Info, error)
func (*Controller) TypeID ¶
func (c *Controller) TypeID() (*TypeID, error)
type ControllerConfig ¶
func DefaultControllerConfig ¶
func DefaultControllerConfig() *ControllerConfig
type DevConfig ¶
type DevConfig struct {
ReadTimeout time.Duration // This is per byte timeout
WriteTimeout time.Duration // This is per byte timeout
}
func DefaultDevConfig ¶
func DefaultDevConfig() *DevConfig
type DrawerEvent ¶
func (DrawerEvent) String ¶
func (e DrawerEvent) String() string
type DrawerStatus ¶
type DrawerStatus byte
func (DrawerStatus) IsPin3 ¶
func (s DrawerStatus) IsPin3() bool
func (DrawerStatus) IsValid ¶
func (s DrawerStatus) IsValid() bool
func (DrawerStatus) String ¶
func (s DrawerStatus) String() string
type ErrorStatus ¶
type ErrorStatus byte
func (ErrorStatus) IsAutoRecoverable ¶
func (s ErrorStatus) IsAutoRecoverable() bool
func (ErrorStatus) IsAutocutter ¶
func (s ErrorStatus) IsAutocutter() bool
func (ErrorStatus) IsRecoverable ¶
func (s ErrorStatus) IsRecoverable() bool
func (ErrorStatus) IsUnrecoverable ¶
func (s ErrorStatus) IsUnrecoverable() bool
func (ErrorStatus) IsValid ¶
func (s ErrorStatus) IsValid() bool
func (ErrorStatus) String ¶
func (s ErrorStatus) String() (str string)
type FeedButtonEvent ¶
func (FeedButtonEvent) String ¶
func (e FeedButtonEvent) String() string
type FileDev ¶
func (*FileDev) UseXonXoff ¶
type FinishPrintEvent ¶
func (FinishPrintEvent) String ¶
func (e FinishPrintEvent) String() string
type FirmwareCmd ¶
type FirmwareCmd struct{}
func (FirmwareCmd) Result ¶
func (c FirmwareCmd) Result(r Res) string
func (FirmwareCmd) String ¶
func (c FirmwareCmd) String() string
type ModelIDCmd ¶
type ModelIDCmd struct{}
func (ModelIDCmd) Result ¶
func (c ModelIDCmd) Result(r Res) *ModelID
func (ModelIDCmd) String ¶
func (c ModelIDCmd) String() string
type ModelIDRes ¶
func (ModelIDRes) Error ¶
func (r ModelIDRes) Error() error
func (ModelIDRes) Res ¶
func (r ModelIDRes) Res() any
func (ModelIDRes) String ¶
func (r ModelIDRes) String() string
type OfflineStatus ¶
type OfflineStatus byte
func (OfflineStatus) IsCoverOpen ¶
func (s OfflineStatus) IsCoverOpen() bool
func (OfflineStatus) IsError ¶
func (s OfflineStatus) IsError() bool
func (OfflineStatus) IsFedByButton ¶
func (s OfflineStatus) IsFedByButton() bool
Is paper being fed by the paper feed button
func (OfflineStatus) IsPaperEnd ¶
func (s OfflineStatus) IsPaperEnd() bool
Is printing stops due to paper-end
func (OfflineStatus) IsValid ¶
func (s OfflineStatus) IsValid() bool
func (OfflineStatus) String ¶
func (s OfflineStatus) String() (str string)
type PaperNearEndEvent ¶
func (PaperNearEndEvent) String ¶
func (e PaperNearEndEvent) String() string
type PaperStatus ¶
type PaperStatus byte
func (PaperStatus) IsNearEnd ¶
func (s PaperStatus) IsNearEnd() bool
func (PaperStatus) IsNoPaper ¶
func (s PaperStatus) IsNoPaper() bool
func (PaperStatus) IsValid ¶
func (s PaperStatus) IsValid() bool
func (PaperStatus) String ¶
func (s PaperStatus) String() (str string)
type ParseError ¶
func (ParseError) Error ¶
func (e ParseError) Error() string
type PressFeedButtonCmd ¶
type PressFeedButtonCmd struct{}
func (PressFeedButtonCmd) String ¶
func (c PressFeedButtonCmd) String() string
type PrinterStatus ¶
type PrinterStatus byte
func (PrinterStatus) IsDrawerPin3 ¶
func (s PrinterStatus) IsDrawerPin3() bool
func (PrinterStatus) IsFeedButton ¶
func (s PrinterStatus) IsFeedButton() bool
Is paper feed button being pressed
func (PrinterStatus) IsOffline ¶
func (s PrinterStatus) IsOffline() bool
func (PrinterStatus) IsRecovery ¶
func (s PrinterStatus) IsRecovery() bool
Is the printer waiting for online recovery?
func (PrinterStatus) IsValid ¶
func (s PrinterStatus) IsValid() bool
func (PrinterStatus) String ¶
func (s PrinterStatus) String() (str string)
type PulseLevelCmd ¶
func (PulseLevelCmd) String ¶
func (c PulseLevelCmd) String() string
func (PulseLevelCmd) Validate ¶
func (c PulseLevelCmd) Validate() error
type RecoverCmd ¶
type RecoverCmd struct{}
func (RecoverCmd) String ¶
func (c RecoverCmd) String() string
type RollStatus ¶
type RollStatus byte
func (RollStatus) IsNearEnd ¶
func (s RollStatus) IsNearEnd() bool
func (RollStatus) IsNoPaper ¶
func (s RollStatus) IsNoPaper() bool
func (RollStatus) IsValid ¶
func (s RollStatus) IsValid() bool
func (RollStatus) String ¶
func (s RollStatus) String() (str string)
type Scanner ¶
type Scanner struct {
Controller *Controller
Config *ScannerConfig
// contains filtered or unexported fields
}
type ScannerConfig ¶
func DefaultScannerConfig ¶
func DefaultScannerConfig() *ScannerConfig
type SerialConfig ¶
func DefaultSerialConfig ¶
func DefaultSerialConfig() *SerialConfig
type SerialDev ¶
type SerialDev struct {
Device string
Config *SerialConfig
}
func (*SerialDev) UseXonXoff ¶
type SerialNoCmd ¶
type SerialNoCmd struct{}
func (SerialNoCmd) Result ¶
func (c SerialNoCmd) Result(r Res) string
func (SerialNoCmd) String ¶
func (c SerialNoCmd) String() string
type StartPrintEvent ¶
func (StartPrintEvent) String ¶
func (e StartPrintEvent) String() string
type StateEvent ¶
func (StateEvent) String ¶
func (e StateEvent) String() string
type TypeID ¶
type TypeID byte