Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raster example command #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
epos-server/epos-server
/cmd/epos-server/epos-server
/cmd/epos-server/epos-server.exe
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# About escpos #

This is a simple [Golang](http://www.golang.org/project) package that provides
[ESC-POS](https://en.wikipedia.org/wiki/ESC/P) library functions to help with
sending control codes to a ESC-POS capable printer such as an Epson TM-T82 or
similar.
This is a simple [Go][1] package that provides [ESC-POS][2] library functions
to help with sending control codes to a ESC-POS capable printer such as an
Epson TM-T82 or similar.

These printers are often used in retail environments in conjunction with a
point-of-sale (POS) system.
Expand All @@ -12,14 +11,13 @@ point-of-sale (POS) system.

Install the package via the following:

go get -u github.com/knq/escpos
go get -u github.com/kenshaw/escpos

## Example epos-server ##

An example EPOS server implementation is available in the
[epos-server](epos-server) subdirectory of this project. This example
server is more or less compatible with [Epson TM-Intelligent](https://c4b.epson-biz.com)
printers and print server implementations.
An example EPOS server implementation is available in the [cmd/epos-server][3]
subdirectory of this project. This example server is more or less compatible
with [Epson TM-Intelligent][4] printers and print server implementations.

## Usage ##

Expand All @@ -32,7 +30,7 @@ import (
"bufio"
"os"

"github.com/knq/escpos"
"github.com/kenshaw/escpos"
)

func main() {
Expand Down Expand Up @@ -86,5 +84,8 @@ func main() {

## TODO
- Fix barcode/image support
- Update code to be idiomatic Go
- Fix example server implementation

[1]: http://www.golang.org/project
[2]: https://en.wikipedia.org/wiki/ESC/P
[3]: cmd/epos-server
[4]: https://c4b.epson-biz.com
17 changes: 9 additions & 8 deletions epos-server/README.md → cmd/epos-server/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# About epos-server #

This is a quick and dirty Golang implementation of a [Epson TM-Intelligent](https://c4b.epson-biz.com/)
print server. This also serves as example code for the
[escpos](https://github.com/knq/escpos) package. This is "more-or-less"
compatible with the ePOS-Print API and shows how ePOS-XML is translated into
simple ESCPOS data.
This is a quick and dirty Golang implementation of a [Epson TM-Intelligent][1]
print server. This also serves as example code for the [escpos][2] package.
This is "more-or-less" compatible with the ePOS-Print API and shows how
ePOS-XML is translated into simple ESCPOS data.

This has been tested and works as expected on Linux.

Expand All @@ -20,12 +19,11 @@ like the following for your system:

Then install via the following:

go get -u github.com/knq/escpos/epos-server

go get -u github.com/kenshaw/escpos/epos-server

You should then be able to build the epos-server like this:

go build github.com/knq/escpos/epos-server
go build github.com/kenshaw/escpos/epos-server

## Usage ##

Expand All @@ -46,3 +44,6 @@ printer:
The following still needs to be implemented:

* Fix image decoding and printing

[1]: https://c4b.epson-biz.com/
[2]: https://github.com/kenshaw/escpos
52 changes: 52 additions & 0 deletions cmd/epos-server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"flag"
"log"
"net/http"
"os"

"github.com/kenshaw/escpos"
)

var (
flagListen = flag.String("l", "127.0.22.8:80", "listen")
flagEndpoint = flag.String("endpoint", escpos.DefaultEndpoint, "endpoint")
flagPrinter = flag.String("p", "", "path to printer")
)

func main() {
flag.Parse()

if *flagPrinter == "" {
log.Fatal("must specify path to printer via -p")
}

// open printer
f, err := os.Create(*flagPrinter)
if err != nil {
panic(err)
}
defer f.Close()

// create printer
ep, err := escpos.NewPrinter(f)
if err != nil {
log.Fatal(err)
}

// create server
s, err := escpos.NewServer(ep)
if err != nil {
log.Fatal(err)
}

// set up mux
mux := http.NewServeMux()
mux.Handle(*flagEndpoint, s)
mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
http.Error(res, http.StatusText(http.StatusNotFound), http.StatusNotFound)
})

log.Fatal(http.ListenAndServe(*flagListen, mux))
}
159 changes: 0 additions & 159 deletions epos-server/epos-server.go

This file was deleted.

Loading