110 lines
3.1 KiB
Go
110 lines
3.1 KiB
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
/*
|
||
|
|
#include <stdint.h>
|
||
|
|
*/
|
||
|
|
"C"
|
||
|
|
"fmt"
|
||
|
|
_ "image/png"
|
||
|
|
|
||
|
|
"github.com/google/gousb"
|
||
|
|
)
|
||
|
|
import (
|
||
|
|
"github.com/google/gousb/usbid"
|
||
|
|
"gt.mokkon.com/sainw/libgofunc"
|
||
|
|
)
|
||
|
|
|
||
|
|
//export Sum
|
||
|
|
func Sum(a, b int) int {
|
||
|
|
return a + b
|
||
|
|
}
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
payload := `{"Name":"Ko Myo","Amount":3000}`
|
||
|
|
const temp = `
|
||
|
|
<img src="logo.png" style="width:230;height:200;padding-left:130px;padding-top:30px"/>
|
||
|
|
<h1 style="padding-left:150px">New Day Energy</h1>
|
||
|
|
|
||
|
|
<p style="padding-left:10px">Address: မင်္ဂလာပါ {{.Name}}</p>
|
||
|
|
<p style="padding-left:10px">Receipt: RCPT001</p>
|
||
|
|
<p style="padding-left:10px">Phone: 0977777777</p>
|
||
|
|
<p style="padding-left:10px">Date: 4 Jan 2026 15:38:38</p>
|
||
|
|
<p style="padding-left:10px">Car No.: 3J/3883</p>
|
||
|
|
<p style="padding-left:10px">Casher: မနှင်းနှင်း</p>
|
||
|
|
<p style="padding-left:10px">MOP: B2B</p>
|
||
|
|
<p style="padding-left:10px">Tier: 1</p>
|
||
|
|
<p style="padding-left:10px">Deal No.: RR</p>
|
||
|
|
<hr style="height:1px;padding-left:10px;padding-right:10px;padding-bottom:10px"/>
|
||
|
|
|
||
|
|
<table style="padding-left:10px;padding-bottom:10px;border:0px;font-size:16px;border:0px;">
|
||
|
|
<tr>
|
||
|
|
<th>Item</th>
|
||
|
|
<th>Pump</th>
|
||
|
|
<th>Price</th>
|
||
|
|
<th>Liter</th>
|
||
|
|
<th>Gallon</th>
|
||
|
|
<th>Amount</th>
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td>95 RON</td>
|
||
|
|
<td>P8</td>
|
||
|
|
<td>2,000</td>
|
||
|
|
<td>3.25</td>
|
||
|
|
<td>0.715</td>
|
||
|
|
<td>6,500</td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
|
||
|
|
<p style="padding-left:0px;padding-top:50px;">
|
||
|
|
စက်သုံးဆီ အရေအတွက် နှင့် အရည်အသွေးစျေးနှုန်းများ အားသံသယရှိပါက ph 09450539099, 09765421033, 09765421029 သို့တိုင်ကြား နိုင်ပါသည်။</p>
|
||
|
|
`
|
||
|
|
result := libgofunc.GenImg(550, "./out.png", payload, temp)
|
||
|
|
fmt.Println("Result:", result)
|
||
|
|
// PrintImg(C.CString("usb:/dev/usb/lp1"), C.CString("build/out.png"))
|
||
|
|
// libgofunc.Print("int:/dev/bus/usb/001/046", "./out.png")
|
||
|
|
libgofunc.Print("tcp:192.168.100.151:9100", "./out.png")
|
||
|
|
// printer := "tcp:192.168.100.151:9100"
|
||
|
|
// ListUSB()
|
||
|
|
}
|
||
|
|
|
||
|
|
func ListUSB() {
|
||
|
|
ctx := gousb.NewContext()
|
||
|
|
defer ctx.Close()
|
||
|
|
|
||
|
|
// OpenDevices returns all devices that return 'true' in the filter
|
||
|
|
devices, _ := ctx.OpenDevices(func(desc *gousb.DeviceDesc) bool {
|
||
|
|
// fmt.Println(usbid.Describe(desc))
|
||
|
|
|
||
|
|
// path := fmt.Sprintf("/dev/bus/usb/%03d/%03d", desc.Bus, desc.Address)
|
||
|
|
// fmt.Printf("Device Path: %s\n", path)
|
||
|
|
|
||
|
|
// switch desc.Class {
|
||
|
|
// case 7:
|
||
|
|
// fmt.Println("Found a standard printer")
|
||
|
|
// case 0xFF:
|
||
|
|
// fmt.Println("Found a vendor-specific device (likely your printer)")
|
||
|
|
// }
|
||
|
|
|
||
|
|
return true // Open every device to read its name
|
||
|
|
})
|
||
|
|
defer func() {
|
||
|
|
for _, d := range devices {
|
||
|
|
|
||
|
|
d.Close()
|
||
|
|
}
|
||
|
|
}()
|
||
|
|
|
||
|
|
for _, d := range devices {
|
||
|
|
fmt.Println(usbid.Describe(d.Desc))
|
||
|
|
fmt.Printf("Bus: %d, Address: %d\n", d.Desc.Bus, d.Desc.Address)
|
||
|
|
// Read human-readable names from the device strings
|
||
|
|
manufacturer, _ := d.Manufacturer()
|
||
|
|
product, _ := d.Product()
|
||
|
|
serial, _ := d.SerialNumber()
|
||
|
|
// d.Desc.Path
|
||
|
|
fmt.Printf("ID: %s:%s | Manufacturer: %s | Product: %s | Serial: %s\n",
|
||
|
|
d.Desc.Vendor, d.Desc.Product, manufacturer, product, serial)
|
||
|
|
}
|
||
|
|
}
|