Skip to content

Commit

Permalink
check for error in WriteByte call to writeByte
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Jul 14, 2023
1 parent 90cbe52 commit c84bdd0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/machine/uart.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ func (uart *UART) WriteByte(c byte) error {
// Write data over the UART's Tx.
// This function blocks until the data is finished being sent.
func (uart *UART) Write(data []byte) (n int, err error) {
for _, v := range data {
uart.writeByte(v)
for i, v := range data {
err = uart.writeByte(v)
if err != nil {
return i, err
}
}
uart.flush() // flush() blocks until all data has been transmitted.
return len(data), nil
Expand Down

0 comments on commit c84bdd0

Please sign in to comment.