Skip to content

Commit

Permalink
Merge pull request #21 from olivercalder/master
Browse files Browse the repository at this point in the history
Added send_raw() function to allow sending arbitrary binary data using the serial port.
  • Loading branch information
phil-opp authored Jan 8, 2022
2 parents 2508703 + e52e06e commit 7beb08b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ name: Build

on:
push:
branches:
- 'master'
tags:
- '*'
pull_request:
schedule:
- cron: '40 4 * * *' # every day at 4:40
pull_request:

jobs:
test:
Expand Down
8 changes: 8 additions & 0 deletions src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ impl SerialPort {
}
}

/// Sends a raw byte on the serial port, intended for binary data.
pub fn send_raw(&mut self, data: u8) {
unsafe {
wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
self.data.write(data);
}
}

/// Receives a byte on the serial port.
pub fn receive(&mut self) -> u8 {
unsafe {
Expand Down

0 comments on commit 7beb08b

Please sign in to comment.