https://github.com/taigrr/xmodem
https://github.com/taigrr/xmodem
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/taigrr/xmodem
- Owner: taigrr
- License: 0bsd
- Created: 2023-11-30T19:00:30.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-05-02T03:08:01.000Z (about 1 year ago)
- Last Synced: 2025-06-20T23:49:53.338Z (12 months ago)
- Language: Go
- Size: 1.86 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# XMODEM
A robust XMODEM implementation in Go that supports XMODEM-CRC and XMODEM-1K protocols.
This library was created to address limitations in existing Go XMODEM implementations, particularly around XMODEM-CRC support.
## Features
- Supports XMODEM-CRC and XMODEM-1K protocols
- Configurable retries and timeouts
- Automatic protocol detection
- Simple API for file transfers
## Usage
### Basic Example
```go
package main
import (
"bytes"
"github.com/taigrr/xmodem"
"github.com/tarm/serial"
)
func main() {
// Create a new XMODEM instance with a serial port
x, err := xmodem.New("/dev/ttyUSB0", 115200)
if err != nil {
panic(err)
}
defer x.port.Close()
// Prepare your data
data := []byte("Hello, XMODEM!")
buffer := bytes.NewBuffer(data)
// Send the data
err = x.Send(*buffer)
if err != nil {
panic(err)
}
}
```
### Advanced Configuration
```go
// Create with existing serial port
port, _ := serial.OpenPort(&serial.Config{
Name: "/dev/ttyUSB0",
Baud: 115200,
})
x := xmodem.NewWithPort(port)
// Configure settings
x.Mode = xmodem.XMode1K // Use XMODEM-1K
x.Padding = 0x1A // Set padding character
x.retries = 5 // Set retry count
x.Timeout = time.Second * 10 // Set timeout
```
## Protocol Support
- XMODEM-CRC (default)
- XMODEM-1K
- XMODEM-128 (checksum mode not implemented)
## References
- [tarm](https://github.com/tarm/serial/blob/master/serial_linux.go)
- [c implementation](https://github.com/kelvinlawson/xmodem-1k/blob/master/xmodem.c#L133)
- [protocol writeup](https://www.adontec.com/xmodem-protocol.htm)
- [nindepedia](https://www.ninerpedia.org/wiki/Protocols)
- [wikipedia](https://en.wikipedia.org/wiki/XMODEM#XMODEM-1K)
- [testing fork](https://github.com/taigrr/go-xmodem)
## Disclaimer
The CRC table implementation in this library is not 0BSD licensed. It is used under fair use for educational and compatibility purposes.
Please refer to the original source for licensing details.