Compare commits

...

No commits in common. "0.0.1" and "main" have entirely different histories.
0.0.1 ... main

3 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,7 @@ func imit() {
logger.SetPrefix("ftdi_switch: ") logger.SetPrefix("ftdi_switch: ")
} }
func start(vendor_id int, product_id int, init_value int) error { func Start(vendor_id int, product_id int, init_value int) error {
var err error var err error
ftdi_device, err = ftdi.OpenFirst(vendor_id, product_id, ftdi.ChannelAny) ftdi_device, err = ftdi.OpenFirst(vendor_id, product_id, ftdi.ChannelAny)
if err != nil { if err != nil {
@ -32,18 +32,18 @@ func start(vendor_id int, product_id int, init_value int) error {
if err != nil { if err != nil {
logger.Println(err) logger.Println(err)
} }
err = write_byte(0) err = Write_byte(0)
if err != nil { if err != nil {
logger.Println(err) logger.Println(err)
} }
return err return err
} }
func stop() error { func Stop() error {
return ftdi_device.Close() return ftdi_device.Close()
} }
func write_bit(bit byte, value bool) error { func Write_bit(bit byte, value bool) error {
if value { if value {
data_byte |= 1 << bit data_byte |= 1 << bit
} else { } else {
@ -52,7 +52,7 @@ func write_bit(bit byte, value bool) error {
return ftdi_device.WriteByte(data_byte) return ftdi_device.WriteByte(data_byte)
} }
func write_byte(data byte) error { func Write_byte(data byte) error {
data_byte = data data_byte = data
return ftdi_device.WriteByte(data_byte) return ftdi_device.WriteByte(data_byte)
} }

View File

@ -16,24 +16,24 @@ func TestMain(t *testing.T) {
logger.Println("Starting") logger.Println("Starting")
var err error var err error
err = start(ID_VENDOR, ID_PRODUCT, 0) err = Start(ID_VENDOR, ID_PRODUCT, 0)
assert.NilError(t, err) assert.NilError(t, err)
err = write_bit(3, true) err = Write_bit(3, true)
assert.NilError(t, err) assert.NilError(t, err)
err = write_bit(5, true) err = Write_bit(5, true)
assert.NilError(t, err) assert.NilError(t, err)
err = write_bit(6, true) err = Write_bit(6, true)
assert.NilError(t, err) assert.NilError(t, err)
err = write_bit(7, true) err = Write_bit(7, true)
assert.NilError(t, err) assert.NilError(t, err)
err = write_byte(0) err = Write_byte(0)
assert.NilError(t, err) assert.NilError(t, err)
err = stop() err = Stop()
assert.NilError(t, err) assert.NilError(t, err)
} }

2
go.mod
View File

@ -1,6 +1,6 @@
module git.blackfinn.de/solar/ftdi_switch module git.blackfinn.de/solar/ftdi_switch
go 1.21.0 go 1.20.0
require ( require (
github.com/ziutek/ftdi v0.0.1 github.com/ziutek/ftdi v0.0.1