Git Product home page Git Product logo

hoin-printer's Introduction

hoin-printer

Go Report Card Software License GoDoc tests

Important

This repo has been moved to joeyak/go-escpos to match the fact that these commands work on other ESC/POS Thermal Printers

This is a package for writing to a HOIN POS-80-Series Thermal Printer

Connect to the printer with an io.ReadWriter and then send commands

package main

import (
	"fmt"
	"net"

	"github.com/joeyak/hoin-printer"
)

func main() {

	conn, err := net.Dial("tcp", "192.168.1.23:9100")
	if err != nil {
		fmt.Println("unable to dial:", err)
		return
	}
	defer conn.Close()

	printer := hoin.NewPrinter(conn)

	for i := 0; i < 5; i++ {
		printer.Println("Hello World!")
	}

	printer.FeedLines(5)
	printer.Cut()
}

Testing

What? Did I hear you ask for testing? You think we make useless mocks that only tests our assumptions about the hoin printer instead of REAL HONEST GOOD boots on the ground testing.

Run go run ./cmd/test-printer/ to print out our test program.

Really, how are we supposed to tests without a firmware dump? Total incongruity.

Also the test program assumes some things will work line printing and the such, cause how can we test functions without that. It'd be obvious if nothing prints. The goal is to test all the extra functions like horizontal tabbing, justifications, images, etc.

hoin-printer's People

Contributors

joeyak avatar zorchenhimer avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

hoin-printer's Issues

Rework SetFont(n int)

How about actual values (a 2 value const) for the possible values instead of an plain int

func (p Printer) SetFont(n int) error {

something like

type Font int

const (
   fontA Font = iota
   fontB
)

That way the equality check for 0 or 1 is handled cleaner imho

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.