Skip to content

Commit 25efe75

Browse files
committed
new version
1 parent 2e88806 commit 25efe75

4 files changed

Lines changed: 41 additions & 31 deletions

File tree

Cargo.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "toledo"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
authors = ["Marco Di Pillo Tomic <marcodpt@protonmail.com>"]
66
license = "MIT"

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@ On ubuntu
66
```
77
sudo apt install libudev-dev pkg-config
88
```
9+
10+
## Releases
11+
Currently, only binaries for generic versions of Linux are distributed across
12+
releases.
13+
```
14+
sudo apt install pkg-config libssl-dev musl-tools
15+
rustup target add x86_64-unknown-linux-musl
16+
cargo build --release --target x86_64-unknown-linux-musl
17+
```

src/main.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::collections::HashMap;
77
use ascii_converter::decimals_to_string;
88
use std::fs::{read, write};
99
use std::path::{PathBuf};
10+
use std::io::Read;
1011
use serialport;
1112

1213
#[derive(Parser)]
@@ -89,12 +90,12 @@ fn bit (num: u8, index: u8) -> bool {
8990
fn parse(raw: &Vec<u8>, cli: &Cli) -> Result<Value, Box<dyn Error>> {
9091
let mut data: Vec<u8> = Vec::new();
9192
for v in raw {
92-
data.push(v % 128);
93+
data.push(if *v > 128 {*v - 128} else {*v});
9394
}
94-
let mut check: u16 = 0;
95+
/*let mut check: u16 = 0;
9596
for i in 0..18 {
9697
check = (check + (data[i] as u16)) % 128;
97-
}
98+
}*/
9899

99100
let weight = decimals_to_string(&data[4..10].to_vec())?;
100101
let tare = decimals_to_string(&data[10..16].to_vec())?;
@@ -116,7 +117,7 @@ fn parse(raw: &Vec<u8>, cli: &Cli) -> Result<Value, Box<dyn Error>> {
116117
stx: data[0],
117118
cr: data[16],
118119
_cs: data[17],
119-
_check: check,
120+
_check: 0,
120121
_a: data[1],
121122
_b: data[2],
122123
_c: data[3]
@@ -192,7 +193,7 @@ fn main() -> Result<(), Box<dyn Error>> {
192193
false => Some(serialport::new(
193194
cli.path.as_path().as_os_str().to_str().ok_or("unreachable")?,
194195
cli.baud_rate
195-
).open()?),
196+
).open_native()?),
196197
true => None
197198
};
198199

0 commit comments

Comments
 (0)