Compare commits

...

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

3 changed files with 13 additions and 13 deletions

View File

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

View File

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

2
go.mod
View File

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