diff --git a/.circleci/config.yml b/.circleci/config.yml index ddfc4b52c..fa074ba3b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -745,20 +745,6 @@ jobs: command: | cargo test -p cacvote-server - test-crate-controllerd: - executor: nodejs - resource_class: xlarge - steps: - - checkout-and-install - - run: - name: Build - command: | - cargo build -p controllerd - - run: - name: Test - command: | - cargo test -p controllerd - test-crate-types-rs: executor: nodejs resource_class: xlarge @@ -850,7 +836,6 @@ workflows: - test-crate-cacvote-jx-terminal-backend - test-crate-cacvote-jx-terminal-frontend - test-crate-cacvote-server - - test-crate-controllerd - test-crate-types-rs - test-crate-ui-rs - test-crate-vx-logging diff --git a/Cargo.lock b/Cargo.lock index d92c88009..5394d9849 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "getrandom", "once_cell", "version_check", @@ -226,7 +226,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edcdbedc2236483ab103a53415653d6b4442ea6141baf1ffa85df29635e88436" dependencies = [ - "nix 0.27.1", + "nix", "rand", ] @@ -259,7 +259,7 @@ dependencies = [ "async-trait", "axum-core", "bitflags 1.3.2", - "bytes 1.5.0", + "bytes", "futures-util", "http", "http-body", @@ -289,7 +289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", - "bytes 1.5.0", + "bytes", "futures-util", "http", "http-body", @@ -307,7 +307,7 @@ checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", @@ -412,16 +412,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bytes" version = "1.5.0" @@ -526,12 +516,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -650,7 +634,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen", ] @@ -666,21 +650,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" -[[package]] -name = "controllerd" -version = "0.1.0" -dependencies = [ - "crc16", - "ctrlc", - "num_enum", - "serde", - "serde_json", - "serialport", - "thiserror", - "uinput", - "vx-logging", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -721,19 +690,13 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" -[[package]] -name = "crc16" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338089f42c427b86394a5ee60ff321da23a5c89c9d89514c829687b26359fcff" - [[package]] name = "crossbeam-queue" version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adc6598521bb5a83d491e8c1fe51db7296019d2ca3cb93cc6c2a20369a4d78a2" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -743,7 +706,7 @@ version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -756,22 +719,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "ctrlc" -version = "3.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" -dependencies = [ - "nix 0.27.1", - "windows-sys 0.52.0", -] - -[[package]] -name = "custom_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" - [[package]] name = "darling" version = "0.20.3" @@ -1059,15 +1006,9 @@ version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] -[[package]] -name = "enum_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406ac2a8c9eedf8af9ee1489bee9e50029278a6456c740f7454cf8a158abc816" - [[package]] name = "enumset" version = "1.1.3" @@ -1111,7 +1052,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "home", "windows-sys 0.48.0", ] @@ -1310,12 +1251,6 @@ dependencies = [ "slab", ] -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - [[package]] name = "generic-array" version = "0.14.7" @@ -1332,7 +1267,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "libc", "wasi", @@ -1517,7 +1452,7 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ - "bytes 1.5.0", + "bytes", "fnv", "futures-core", "futures-sink", @@ -1618,7 +1553,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ - "bytes 1.5.0", + "bytes", "fnv", "itoa", ] @@ -1629,7 +1564,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes 1.5.0", + "bytes", "http", "pin-project-lite", ] @@ -1658,7 +1593,7 @@ version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ - "bytes 1.5.0", + "bytes", "futures-channel", "futures-core", "futures-util", @@ -1682,7 +1617,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 1.5.0", + "bytes", "hyper", "native-tls", "tokio", @@ -1751,7 +1686,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b84ee245c606aeb0841649a9288e3eae8c61b853a8cd5c0e14450e96d53d28f" dependencies = [ "blocking", - "cfg-if 1.0.0", + "cfg-if", "futures-core", "futures-io", "intmap", @@ -1770,31 +1705,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae52f28f45ac2bc96edb7714de995cffc174a395fb0abf5bff453587c980d7b9" -[[package]] -name = "io-kit-sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4769cb30e5dcf1710fc6730d3e94f78c47723a014a567de385e113c737394640" -dependencies = [ - "core-foundation-sys", - "mach2", -] - -[[package]] -name = "ioctl-sys" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2c4b26352496eaaa8ca7cfa9bd99e93419d3f7983dc6e99c2a35fe9e33504a" - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "ipnet" version = "2.9.0" @@ -1868,36 +1778,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "libudev" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe" -dependencies = [ - "libc", - "libudev-sys", -] - -[[package]] -name = "libudev" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b324152da65df7bb95acfcaab55e3097ceaab02fb19b228a9eb74d55f135e0" -dependencies = [ - "libc", - "libudev-sys", -] - -[[package]] -name = "libudev-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -dependencies = [ - "libc", - "pkg-config", -] - [[package]] name = "linux-raw-sys" version = "0.4.12" @@ -1935,15 +1815,6 @@ dependencies = [ "hashbrown 0.12.3", ] -[[package]] -name = "mach2" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" -dependencies = [ - "libc", -] - [[package]] name = "matchers" version = "0.1.0" @@ -1965,7 +1836,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "digest", ] @@ -2044,31 +1915,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nix" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7fd5681d13fda646462cfbd4e5f2051279a89a544d50eb98c365b507246839f" -dependencies = [ - "bitflags 1.3.2", - "bytes 0.4.12", - "cfg-if 0.1.10", - "gcc", - "libc", - "void", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", -] - [[package]] name = "nix" version = "0.27.1" @@ -2076,7 +1922,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ "bitflags 2.4.1", - "cfg-if 1.0.0", + "cfg-if", "libc", ] @@ -2158,27 +2004,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.46", -] - [[package]] name = "object" version = "0.32.2" @@ -2201,7 +2026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ "bitflags 2.4.1", - "cfg-if 1.0.0", + "cfg-if", "foreign-types", "libc", "once_cell", @@ -2281,7 +2106,7 @@ version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "redox_syscall", "smallvec", @@ -2294,15 +2119,6 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" -[[package]] -name = "patinputd" -version = "0.1.0" -dependencies = [ - "ctrlc", - "uinput", - "vx-logging", -] - [[package]] name = "pcsc" version = "2.8.2" @@ -2439,16 +2255,6 @@ dependencies = [ "syn 2.0.46", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" -dependencies = [ - "toml_datetime", - "toml_edit", -] - [[package]] name = "proc-macro2" version = "1.0.74" @@ -2592,7 +2398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "base64", - "bytes 1.5.0", + "bytes", "encoding_rs", "futures-core", "futures-util", @@ -2884,32 +2690,13 @@ dependencies = [ "serde", ] -[[package]] -name = "serialport" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5a15d0be940df84846264b09b51b10b931fb2f275becb80934e3568a016828" -dependencies = [ - "bitflags 2.4.1", - "cfg-if 1.0.0", - "core-foundation-sys", - "io-kit-sys", - "libudev 0.3.0", - "mach2", - "nix 0.26.4", - "regex", - "scopeguard", - "unescaper", - "winapi", -] - [[package]] name = "sha1" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest", ] @@ -2920,7 +2707,7 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest", ] @@ -3063,7 +2850,7 @@ dependencies = [ "ahash 0.8.7", "atoi", "byteorder", - "bytes 1.5.0", + "bytes", "crc", "crossbeam-queue", "dotenvy", @@ -3149,7 +2936,7 @@ dependencies = [ "base64", "bitflags 2.4.1", "byteorder", - "bytes 1.5.0", + "bytes", "crc", "digest", "dotenvy", @@ -3327,7 +3114,7 @@ version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fastrand", "redox_syscall", "rustix", @@ -3360,7 +3147,7 @@ version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", ] @@ -3421,7 +3208,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", - "bytes 1.5.0", + "bytes", "libc", "mio", "num_cpus", @@ -3469,7 +3256,7 @@ version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ - "bytes 1.5.0", + "bytes", "futures-core", "futures-sink", "pin-project-lite", @@ -3477,23 +3264,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" -dependencies = [ - "indexmap", - "toml_datetime", - "winnow", -] - [[package]] name = "tower" version = "0.4.13" @@ -3517,7 +3287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "bitflags 2.4.1", - "bytes 1.5.0", + "bytes", "futures-core", "futures-util", "http", @@ -3670,45 +3440,12 @@ dependencies = [ "web-sys", ] -[[package]] -name = "uinput" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b074d55c90be32a89a063fe3f944c0ceed0a8e3291369a99809f18fa326685b" -dependencies = [ - "custom_derive", - "enum_derive", - "libc", - "libudev 0.2.0", - "nix 0.10.0", - "uinput-sys", -] - -[[package]] -name = "uinput-sys" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aabddd8174ccadd600afeab346bb276cb1db5fafcf6a7c5c5708b8cc4b2cac7" -dependencies = [ - "ioctl-sys", - "libc", -] - [[package]] name = "unarray" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" -[[package]] -name = "unescaper" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f0f68e58d297ba8b22b8b5a96a87b863ba6bb46aaf51e19a4b02c5a6dd5b7f" -dependencies = [ - "thiserror", -] - [[package]] name = "unicase" version = "2.7.0" @@ -3809,12 +3546,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "vx-logging" version = "0.1.0" @@ -3853,7 +3584,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] @@ -3878,7 +3609,7 @@ version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", @@ -4109,22 +3840,13 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" -[[package]] -name = "winnow" -version = "0.5.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" -dependencies = [ - "memchr", -] - [[package]] name = "winreg" version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "windows-sys 0.48.0", ] diff --git a/Cargo.toml b/Cargo.toml index 0a8658bd8..949baccaa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,6 @@ [workspace] resolver = "2" members = [ - "apps/mark-scan/accessible-controller", - "apps/mark-scan/pat-device-input", "apps/cacvote-jx-terminal/backend", "apps/cacvote-jx-terminal/frontend", "libs/auth-rs", diff --git a/apps/mark-scan/accessible-controller/Cargo.toml b/apps/mark-scan/accessible-controller/Cargo.toml deleted file mode 100644 index e5e076ee2..000000000 --- a/apps/mark-scan/accessible-controller/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "controllerd" -version = "0.1.0" -edition = "2021" - -[[bin]] -name = "controllerd" -path = "src/controllerd.rs" - -[dependencies] -crc16 = { workspace = true } -ctrlc = { workspace = true } -num_enum = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -serialport = { workspace = true } -thiserror = { workspace = true } -vx-logging = { workspace = true } -uinput = { workspace = true } diff --git a/apps/mark-scan/accessible-controller/Makefile b/apps/mark-scan/accessible-controller/Makefile deleted file mode 100644 index e170812a7..000000000 --- a/apps/mark-scan/accessible-controller/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# a phony dependency that can be used as a dependency to force builds -FORCE: - -build: FORCE - mkdir -p target && cargo build --release --target-dir target/. - -run: - ./target/release/controllerd - diff --git a/apps/mark-scan/accessible-controller/README.md b/apps/mark-scan/accessible-controller/README.md deleted file mode 100644 index cc23ca205..000000000 --- a/apps/mark-scan/accessible-controller/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# Accessible controller daemon - -The accessible controller daemon listens for incoming signal from the VSAP 155 accessible controller. It receives button press events and emits keyboard keypress events to be consumed by the frontend. - -## Overview - -The daemon: - -1. Connects to the accessible controller at /dev/ttyACM1 via serial port -2. Listens in a loop for button press signal from the device -3. When button signal is received, emits the corresponding keypress event using `uinput` - -## Usage - -To build: - -``` -cd apps/mark-scan/accessible-controller -make build -``` - -To run: - -``` -// From apps/mark-scan/accessible-controller -sudo ./target/release/controllerd -``` - -To test: - -``` -sudo -E /home/vx/.cargo/bin/cargo test -``` - -`sudo` is needed for the last 2 commands to access `/dev/uinput` and `/dev/tty*`. udev rule configuration is on the backlog. - diff --git a/apps/mark-scan/accessible-controller/src/controllerd.rs b/apps/mark-scan/accessible-controller/src/controllerd.rs deleted file mode 100644 index 33a6d09f6..000000000 --- a/apps/mark-scan/accessible-controller/src/controllerd.rs +++ /dev/null @@ -1,481 +0,0 @@ -//! Daemon whose purpose is to expose signal from VSAP's accessible controller -//! to the mark-scan application. -//! -//! Signal from the accessible controller is available in userspace over -//! the serialport protocol. The daemon connects to the controller and polls -//! for change in signal value. When a button press is detected, it sends -//! a keypress event for consumption by the mark-scan application. - -use serialport::{self, SerialPort}; -use std::{ - io, - process::exit, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread, - time::{Duration, Instant}, -}; -use uinput::{ - event::{keyboard, Keyboard}, - Device, -}; -use vx_logging::{log, set_app_name, Disposition, EventId, EventType}; - -const APP_NAME: &str = "vx-mark-scan-controller-daemon"; -const POLL_INTERVAL: Duration = Duration::from_millis(50); -const MAX_ECHO_RESPONSE_WAIT: Duration = Duration::from_secs(5); -const UINPUT_PATH: &str = "/dev/uinput"; -const DEVICE_PATH: &str = "/dev/ttyACM1"; -const DEVICE_BAUD_RATE: u32 = 9600; - -#[derive(Debug, thiserror::Error)] -enum CommandError { - #[error("Unexpected command data length: {0}")] - UnexpectedPacketSize(usize), - #[error("Unexpected data length reported: {0}")] - UnexpectedDataLength(u16), - #[error("Invalid command received: {0}")] - InvalidCommand(u8), - #[error("Invalid action received: {0}")] - InvalidAction(u8), - #[error("Error occurred when sending keypress event")] - KeypressError(#[from] uinput::Error), - #[error("Button value invalid: {0}")] - InvalidButton(u8), - #[error("Invalid CRC16 value: expected {expected:x}, actual {actual:x}")] - InvalidCrc { expected: u16, actual: u16 }, -} - -#[derive(Debug, num_enum::TryFromPrimitive, Clone, Copy)] -#[repr(u8)] -enum CommandId { - Echo = 0x10, - ButtonStatus = 0x30, -} - -#[derive(Debug)] -struct EchoCommand { - payload: Vec, -} - -impl EchoCommand { - const fn new(payload: Vec) -> Self { - Self { payload } - } -} - -impl From for Vec { - fn from(command: EchoCommand) -> Self { - let payload_length = u16::try_from(command.payload.len()).expect("Payload too large"); - let mut bytes = Self::new(); - bytes.push(CommandId::Echo as u8); - bytes.extend_from_slice(&payload_length.to_be_bytes()); - bytes.extend(command.payload); - bytes.extend_from_slice(&crc16::State::::calculate(&bytes).to_be_bytes()); - bytes - } -} - -fn validate_payload_length( - payload_length: u16, - bytes: &[u8], - non_payload_bytes: usize, -) -> Result<(), CommandError> { - if payload_length as usize != bytes.len() - non_payload_bytes { - return Err(CommandError::UnexpectedDataLength(payload_length)); - } - - Ok(()) -} - -impl TryFrom<&[u8]> for EchoCommand { - type Error = CommandError; - - fn try_from(bytes: &[u8]) -> Result { - const NON_PAYLOAD_BYTES: usize = 5; - const PAYLOAD_OFFSET: usize = 3; - - if bytes.len() < NON_PAYLOAD_BYTES { - return Err(CommandError::UnexpectedPacketSize(bytes.len())); - } - - match CommandId::try_from(bytes[0]) { - Ok(CommandId::Echo) => (), - _ => return Err(CommandError::InvalidCommand(bytes[0])), - } - - let payload_length = u16::from_be_bytes([bytes[1], bytes[2]]); - validate_payload_length(payload_length, bytes, NON_PAYLOAD_BYTES)?; - - let expected_crc = u16::from_be_bytes([bytes[5], bytes[6]]); - let actual_crc = crc16::State::::calculate( - &bytes[..PAYLOAD_OFFSET + payload_length as usize], - ); - - if expected_crc != actual_crc { - return Err(CommandError::InvalidCrc { - expected: expected_crc, - actual: actual_crc, - }); - } - - Ok(Self { - payload: bytes[PAYLOAD_OFFSET..PAYLOAD_OFFSET + payload_length as usize].to_vec(), - }) - } -} - -#[derive(Debug)] -struct ButtonStatusCommand { - button: Button, - action: Action, -} - -impl From for Vec { - fn from(command: ButtonStatusCommand) -> Self { - let mut bytes = Self::new(); - bytes.push(CommandId::ButtonStatus as u8); - bytes.extend_from_slice(&2u16.to_be_bytes()); - bytes.push(command.button as u8); - bytes.push(command.action as u8); - bytes.extend_from_slice(&crc16::State::::calculate(&bytes).to_be_bytes()); - bytes - } -} - -impl TryFrom<&[u8]> for ButtonStatusCommand { - type Error = CommandError; - - // The expected format of a data packet for key status command is 7 bytes total: - // 1 byte command ID, constant 0x30 - // 2 bytes payload size, constant 0x0002 - // 1 byte key ID - // 1 byte key status - // 2 bytes CRC validation value - fn try_from(bytes: &[u8]) -> Result { - const NON_PAYLOAD_BYTES: usize = 5; - const PAYLOAD_OFFSET: usize = 3; - - if bytes.len() < NON_PAYLOAD_BYTES { - return Err(CommandError::UnexpectedPacketSize(bytes.len())); - } - - match CommandId::try_from(bytes[0]) { - Ok(CommandId::ButtonStatus) => (), - _ => return Err(CommandError::InvalidCommand(bytes[0])), - } - - let payload_length = u16::from_be_bytes([bytes[1], bytes[2]]); - validate_payload_length(payload_length, bytes, NON_PAYLOAD_BYTES)?; - - let expected_crc = u16::from_be_bytes([bytes[5], bytes[6]]); - let actual_crc = crc16::State::::calculate( - &bytes[..PAYLOAD_OFFSET + payload_length as usize], - ); - - if expected_crc != actual_crc { - return Err(CommandError::InvalidCrc { - expected: expected_crc, - actual: actual_crc, - }); - } - - let button = - Button::try_from(bytes[3]).map_err(|err| CommandError::InvalidButton(err.number))?; - let action = - Action::try_from(bytes[4]).map_err(|err| CommandError::InvalidAction(err.number))?; - - Ok(Self { button, action }) - } -} - -#[derive(Debug, num_enum::TryFromPrimitive, PartialEq)] -#[repr(u8)] -enum Button { - RateUp = 0x00, - RateDown = 0x01, - Select = 0x02, - VolumeUp = 0x03, - VolumeDown = 0x04, - Right = 0x05, - Left = 0x06, - Up = 0x07, - Down = 0x08, - Help = 0x09, - Pause = 0x0A, -} - -#[derive(Debug, num_enum::TryFromPrimitive)] -#[repr(u8)] -enum Action { - Released = 0x00, - Pressed = 0x01, -} - -fn send_key(device: &mut Device, key: keyboard::Key) -> Result<(), CommandError> { - device.click(&key)?; - device.synchronize()?; - Ok(()) -} - -fn handle_command(data: &[u8]) -> Result, CommandError> { - let ButtonStatusCommand { button, action } = data.try_into()?; - - let key: keyboard::Key; - match action { - Action::Pressed => match button { - Button::Select => { - key = keyboard::Key::Enter; - } - Button::Left => { - key = keyboard::Key::Left; - } - Button::Right => { - key = keyboard::Key::Right; - } - Button::Up => { - key = keyboard::Key::Up; - } - Button::Down => { - key = keyboard::Key::Down; - } - Button::Help => key = keyboard::Key::R, - Button::RateDown => { - key = keyboard::Key::Comma; - } - Button::RateUp => { - key = keyboard::Key::Dot; - } - Button::VolumeDown => { - key = keyboard::Key::Minus; - } - Button::VolumeUp => { - key = keyboard::Key::Equal; - } - Button::Pause => { - key = keyboard::Key::P; - } - }, - Action::Released => { - // Button release is a no-op since we already sent the keypress event - return Ok(None); - } - } - Ok(Some(key)) -} - -fn validate_connection(port: &mut Box) -> Result<(), io::Error> { - let echo_command = EchoCommand::new(vec![0x01, 0x02, 0x03, 0x04, 0x05]); - let echo_command: Vec = echo_command.into(); - match port.write(&echo_command) { - Ok(_) => log!(EventId::ControllerHandshakeInit; EventType::SystemAction), - Err(error) => eprintln!("{error:?}"), - } - - let mut serial_buf: Vec = vec![0; 20]; - - let start_time = Instant::now(); - loop { - match port.read(serial_buf.as_mut_slice()) { - Ok(size) => { - let echo_response = &serial_buf[..size]; - assert_eq!( - echo_command, echo_response, - "Received different response from echo command: {echo_response:x?}" - ); - - log!( - event_id: EventId::ControllerHandshakeComplete, - event_type: EventType::SystemAction, - disposition: Disposition::Success - ); - return Ok(()); - } - Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (), - Err(e) => { - log!( - event_id: EventId::ControllerHandshakeComplete, - message: format!("Error reading echo response: {e:?}"), - event_type: EventType::SystemAction, - disposition: Disposition::Failure - ); - } - } - - if start_time.elapsed() >= MAX_ECHO_RESPONSE_WAIT { - break; - } - - thread::sleep(POLL_INTERVAL); - } - - log!( - event_id: EventId::ControllerHandshakeComplete, - message: "No echo response received".to_string(), - event_type: EventType::SystemAction, - disposition: Disposition::Failure - ); - Err(io::Error::new( - io::ErrorKind::TimedOut, - "No echo response received", - )) -} - -fn create_virtual_device() -> Device { - uinput::open(UINPUT_PATH) - .unwrap() - .name("Accessible Controller Daemon Virtual Device") - .unwrap() - .event(Keyboard::All) - .unwrap() - .create() - .unwrap() -} - -fn main() { - set_app_name(APP_NAME); - log!( - EventId::ProcessStarted; - EventType::SystemAction - ); - - let running = Arc::new(AtomicBool::new(true)); - - if let Err(e) = ctrlc::set_handler({ - let running = running.clone(); - move || { - running.store(false, Ordering::SeqCst); - } - }) { - log!( - event_id: EventId::ErrorSettingSigintHandler, - message: e.to_string(), - event_type: EventType::SystemStatus - ); - } - - // Create virtual device for keypress events - log!( - EventId::CreateVirtualUinputDeviceInit; - EventType::SystemAction - ); - let mut device = create_virtual_device(); - // Wait for virtual device to register - thread::sleep(Duration::from_secs(1)); - log!( - event_id: EventId::CreateVirtualUinputDeviceComplete, - disposition: Disposition::Success, - event_type: EventType::SystemAction - ); - - log!( - EventId::ControllerConnectionInit; - EventType::SystemAction - ); - - // Open the serial port - let port = serialport::new(DEVICE_PATH, DEVICE_BAUD_RATE) - .timeout(POLL_INTERVAL) - .open(); - - match port { - Ok(mut port) => { - validate_connection(&mut port).unwrap(); - - log!( - event_id: EventId::ControllerConnectionComplete, - message: format!("Receiving data on {DEVICE_PATH} at {DEVICE_BAUD_RATE} baud"), - event_type: EventType::SystemAction, - disposition: Disposition::Success - ); - - let mut serial_buf: Vec = vec![0; 1000]; - loop { - if !running.load(Ordering::SeqCst) { - log!( - EventId::ProcessTerminated; - EventType::SystemAction - ); - exit(0); - } - match port.read(serial_buf.as_mut_slice()) { - Ok(size) => match handle_command(&serial_buf[..size]) { - Ok(Some(key)) => { - if let Err(err) = send_key(&mut device, key) { - log!(EventId::UnknownError, "Error sending key: {err}"); - } - } - Ok(None) => {} - Err(err) => log!( - event_id: EventId::UnknownError, - message: format!( - "Unexpected error when handling controller command: {err}" - ), - event_type: EventType::SystemStatus - ), - }, - // Timeout error just means no event was sent in the current polling period - Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (), - Err(e) => { - log!( - event_id: EventId::UnknownError, - message: format!("Unexpected error when opening serial port: {e}"), - event_type: EventType::SystemStatus - ); - } - } - } - } - Err(e) => { - log!( - event_id: EventId::ControllerConnectionComplete, - message: format!("Failed to open {DEVICE_PATH}. Error: {e}"), - event_type: EventType::SystemAction, - disposition: Disposition::Failure - ); - exit(1); - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_handle_command_packet_length_error() { - let bad_data = [0x01]; - match handle_command(&bad_data) { - Err(CommandError::UnexpectedPacketSize(size)) => assert_eq!(size, 1), - result => panic!("Unexpected result: {result:?}"), - } - } - - #[test] - fn test_handle_command_data_length() { - let bad_data_length: u8 = 0x03; - let bad_data = [0x30, 0x00, bad_data_length, 0x00, 0x00, 0x00, 0x00]; - match handle_command(&bad_data) { - Err(CommandError::UnexpectedDataLength(length)) => { - assert_eq!(length, bad_data_length as u16) - } - result => panic!("Unexpected result: {result:?}"), - } - } - - #[test] - fn test_handle_command_success() { - let data = [ - 0x30, - 0x00, - 0x02, - Button::Help as u8, - Action::Pressed as u8, - 0xc8, - 0x37, - ]; - assert_eq!(handle_command(&data).unwrap().unwrap(), keyboard::Key::R); - } -} diff --git a/apps/mark-scan/pat-device-input/Cargo.toml b/apps/mark-scan/pat-device-input/Cargo.toml deleted file mode 100644 index a76f8390b..000000000 --- a/apps/mark-scan/pat-device-input/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "patinputd" -version = "0.1.0" -edition = "2021" - -[[bin]] -name = "patinputd" -path = "src/patinputd.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ctrlc = { workspace = true } -vx-logging = { workspace = true } -uinput = { workspace = true } diff --git a/apps/mark-scan/pat-device-input/Makefile b/apps/mark-scan/pat-device-input/Makefile deleted file mode 100644 index 539c12cf3..000000000 --- a/apps/mark-scan/pat-device-input/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# a phony dependency that can be used as a dependency to force builds -FORCE: - -build-debug: FORCE - mkdir -p target && cargo build --target-dir target/. - -build: FORCE - mkdir -p target && cargo build --release --target-dir target/. - -run: - ./target/release/patinputd - diff --git a/apps/mark-scan/pat-device-input/src/patinputd.rs b/apps/mark-scan/pat-device-input/src/patinputd.rs deleted file mode 100644 index 22f172ef6..000000000 --- a/apps/mark-scan/pat-device-input/src/patinputd.rs +++ /dev/null @@ -1,149 +0,0 @@ -//! Daemon whose purpose is to expose signal from VSAP's input for personal -//! assistive technology (PAT) devices to the mark-scan application. -//! -//! PAT input status is made accessible in userspace with GPIO pins. The daemon -//! connects to the pins then polls their values. When a change in value is read, -//! the daemon sends a keypress event for consumption by the application. -//! -//! Notably, running this daemon is required for the mark-scan app to read PAT -//! device connection status. - -use pin::Pin; -use std::{ - io, - process::exit, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - thread, - time::Duration, -}; -use uinput::{ - event::{keyboard, Keyboard}, - Device, -}; - -use vx_logging::{log, set_app_name, types::EventType, Disposition, EventId}; - -mod pin; - -const UINPUT_PATH: &str = "/dev/uinput"; -const POLL_INTERVAL: Duration = Duration::from_millis(50); -const APP_NAME: &str = "vx-mark-scan-pat-input-daemon"; -const IS_CONNECTED_PIN: Pin = Pin::new(478); -const SIGNAL_A_PIN: Pin = Pin::new(481); -const SIGNAL_B_PIN: Pin = Pin::new(476); - -fn send_key(device: &mut Device, key: keyboard::Key) -> Result<(), uinput::Error> { - device.click(&key)?; - device.synchronize()?; - Ok(()) -} - -fn create_virtual_device() -> Device { - uinput::open(UINPUT_PATH) - .unwrap() - .name("PAT Input Daemon Virtual Device") - .unwrap() - .event(Keyboard::All) - .unwrap() - .create() - .unwrap() -} - -fn set_up_pins() -> io::Result<()> { - IS_CONNECTED_PIN.set_up()?; - SIGNAL_A_PIN.set_up()?; - SIGNAL_B_PIN.set_up()?; - Ok(()) -} - -fn main() { - set_app_name(APP_NAME); - log!(EventId::ProcessStarted; EventType::SystemAction); - - let running = Arc::new(AtomicBool::new(true)); - - if let Err(e) = ctrlc::set_handler({ - let running = running.clone(); - move || { - running.store(false, Ordering::SeqCst); - } - }) { - log!( - event_id: EventId::ErrorSettingSigintHandler, - message: e.to_string(), - event_type: EventType::SystemStatus - ); - } - - // Create virtual device for keypress events - log!(EventId::CreateVirtualUinputDeviceInit; EventType::SystemAction); - let mut device = create_virtual_device(); - // Wait for virtual device to register - thread::sleep(Duration::from_secs(1)); - log!( - event_id: EventId::CreateVirtualUinputDeviceComplete, - disposition: Disposition::Success, - event_type: EventType::SystemAction - ); - - log!(EventId::ConnectToPatInputInit); - - // Export pins and set direction - if let Err(err) = set_up_pins() { - log!( - event_id: EventId::ConnectToPatInputComplete, - disposition: Disposition::Failure, - message: format!("An error occurred during GPIO pin connection: {err}") - ); - exit(1); - }; - - // is_connected is unused for keypresses in this daemon but it's important to export - // the pin so it can be read by the mark-scan backend - let is_connected = IS_CONNECTED_PIN.is_active(); - let mut signal_a = SIGNAL_A_PIN.is_active(); - let mut signal_b = SIGNAL_B_PIN.is_active(); - - log!( - EventId::ConnectToPatInputInit, - "Connected to PAT with initial values [is_connected={is_connected}], [signal_a={signal_a}], [signal_b={signal_b}]" - ); - - loop { - if !running.load(Ordering::SeqCst) { - log!(EventId::ProcessTerminated; EventType::SystemAction); - IS_CONNECTED_PIN.tear_down(); - SIGNAL_A_PIN.tear_down(); - SIGNAL_B_PIN.tear_down(); - exit(0); - } - - let new_signal_a = SIGNAL_A_PIN.is_active(); - let new_signal_b = SIGNAL_B_PIN.is_active(); - - if new_signal_a && !signal_a { - if let Err(err) = send_key(&mut device, keyboard::Key::_1) { - log!( - EventId::PatDeviceError, - "Error sending 1 keypress event: {err}" - ); - } - } - if new_signal_b && !signal_b { - if let Err(err) = send_key(&mut device, keyboard::Key::_2) { - log!( - EventId::PatDeviceError, - "Error sending 2 keypress event: {err}" - ); - } - } - - signal_a = new_signal_a; - signal_b = new_signal_b; - - thread::sleep(POLL_INTERVAL); - } -} diff --git a/apps/mark-scan/pat-device-input/src/pin.rs b/apps/mark-scan/pat-device-input/src/pin.rs deleted file mode 100644 index 1fb855acf..000000000 --- a/apps/mark-scan/pat-device-input/src/pin.rs +++ /dev/null @@ -1,120 +0,0 @@ -use std::{ - fmt, - fs::{self, File}, - io::{self, Read}, -}; - -use vx_logging::{log, EventId}; - -const EXPORT_PIN_FILEPATH: &str = "/sys/class/gpio/export"; -const UNEXPORT_PIN_FILEPATH: &str = "/sys/class/gpio/unexport"; - -/// Pin provides an interface to read GPIO pins that support the sysfs protocol. -/// -/// # Example -/// -/// ``` -/// const PIN_NUMBER = 478; -/// const MY_PIN: Pin = Pin::new(PIN_NUMBER); -/// MY_PIN.set_up()?; -/// let is_active = MY_PIN.is_active(); -/// do_something_with_value(is_active); -/// ``` -pub struct Pin { - address: u16, -} - -impl Pin { - /// Creates a new instance of Pin at the given address (pin number). - pub const fn new(address: u16) -> Self { - Self { address } - } - - // Exports the pin to be globally accessible from userspace. - fn export(&self) -> io::Result<()> { - fs::write(EXPORT_PIN_FILEPATH, self.to_string()) - } - - // Unexports the pin, removing access from userspace. - fn unexport(&self) -> io::Result<()> { - fs::write(UNEXPORT_PIN_FILEPATH, self.to_string()) - } - - // Sets the pin direction to "in" so its value is readable. Must be called after - // `export` - fn set_direction_in(&self) -> io::Result<()> { - let filepath = format!("/sys/class/gpio/gpio{self}/direction"); - fs::write(filepath, b"in") - } - - /// Removes access to the pin from userspace. - pub fn tear_down(&self) { - self.unexport() - .expect("Unexpected failure to tear down pin"); - } - - /// Makes the pin accessible from userspace. If the pin is already set up due to - /// a previous `set_up` call, or from other callers of the sysfs interface, `set_up` - /// will tear down the pin and attempt one more time to set up. This may cause - /// interruption to other processes attempting to read the pin value. - pub fn set_up(&self) -> io::Result<()> { - if let Err(err) = self.export() { - log!( - EventId::Unspecified, - "Pin {self} export failed with err {err}. Attempting to unexport.", - ); - self.unexport()?; - log!(EventId::Unspecified, "Unexported pin {self} successfully"); - self.export()?; - } - - self.set_direction_in() - } - - /// Reads the pin value and returns the boolean inverse of the pin's raw value. - /// # Example - /// When the pin's value is b'0', `is_active` returns true. - pub fn is_active(&self) -> bool { - let filepath = format!("/sys/class/gpio/gpio{self}/value"); - let Ok(mut file) = File::open(filepath) else { - log!( - EventId::PatDeviceError, - "Failed to open file for pin {self}", - ); - return false; - }; - - let mut buf = [0; 1]; - if let Err(e) = file.read_exact(&mut buf) { - log!( - EventId::PatDeviceError, - "Failed to read file for pin {self}: {e}", - ); - return false; - } - - // Pin status does not follow boolean convention. We translate to typical - // boolean convention here. - // 1 is the default state, 0 is actioned state - // connection status: 1 when PAT device is not plugged in, 0 when plugged in - // A/B signal: 1 when no signal is sent from device, 0 when signal is sent - match buf[0] { - b'0' => true, - b'1' => false, - _ => { - log!( - EventId::PatDeviceError, - "Unexpected value for pin #{self}: {char}", - char = buf[0] as char, - ); - false - } - } - } -} - -impl fmt::Display for Pin { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.address) - } -} diff --git a/libs/monorepo-utils/src/cargo.ts b/libs/monorepo-utils/src/cargo.ts index cb5e3d384..68a6d57f9 100644 --- a/libs/monorepo-utils/src/cargo.ts +++ b/libs/monorepo-utils/src/cargo.ts @@ -3,10 +3,6 @@ import { lines } from '@votingworks/basics'; import { relative } from 'path'; import { getAbsoluteRootPath } from './dependencies'; -// Ballot interpreter tests are already run by the pnpm package test job -// patinputd has no tests currently -const EXCLUDED_PACKAGE_IDS = ['ballot-interpreter', 'patinputd']; - /** * Information about Rust cargo crates in the monorepo. */ @@ -43,10 +39,6 @@ export function getCargoCrates(root: string): Promise { const version = match[2] as string; const absolutePath = match[3] as string; - if (EXCLUDED_PACKAGE_IDS.includes(name)) { - return; - } - const workspacePath = relative(absoluteRootPath, absolutePath); return { name, version, absolutePath, workspacePath }; }) diff --git a/libs/monorepo-utils/src/circleci.test.ts b/libs/monorepo-utils/src/circleci.test.ts index 7a8525a2e..8451cd7f3 100644 --- a/libs/monorepo-utils/src/circleci.test.ts +++ b/libs/monorepo-utils/src/circleci.test.ts @@ -10,5 +10,5 @@ test('generateConfig', async () => { generateConfig(getWorkspacePackageInfo(root), await getCargoCrates(root)) ).join(); expect(config).toContain('test-libs-basics'); - expect(config).toContain('test-crate-controllerd'); + expect(config).toContain('test-crate-types-rs'); });