use rust 1.32.0 to_be_bytes instead
This commit is contained in:
parent
a1e402de7e
commit
b784982f9e
3 changed files with 7 additions and 11 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -1,3 +1,5 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.2.6"
|
||||
|
|
@ -24,7 +26,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "w5500"
|
||||
version = "0.1.5"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"embedded-hal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "w5500"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
authors = ["Michael Watzko <michael@watzko.de>"]
|
||||
repository = "https://github.com/kellerkindt/w5500.git"
|
||||
description = "W5500 IoT Controller implementation. Currently UDP sending and receiving is working. WIP"
|
||||
|
|
|
|||
12
src/lib.rs
12
src/lib.rs
|
|
@ -417,8 +417,8 @@ impl<E> Udp<E> for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) {
|
|||
|
||||
{
|
||||
let local_port = w5500.read_u16(socket.at(SocketRegister::LocalPort))?;
|
||||
let local_port = u16_to_be_bytes(local_port);
|
||||
let host_port = u16_to_be_bytes(host_port);
|
||||
let local_port = local_port.to_be_bytes();
|
||||
let host_port = host_port.to_be_bytes();
|
||||
|
||||
w5500.write_to(
|
||||
socket.at(SocketRegister::LocalPort),
|
||||
|
|
@ -443,7 +443,7 @@ impl<E> Udp<E> for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) {
|
|||
|
||||
let data_length = data.len() as u16;
|
||||
{
|
||||
let data_length = u16_to_be_bytes(data_length);
|
||||
let data_length = data_length.to_be_bytes();
|
||||
|
||||
// TODO why write [0x00, 0x00] at TxReadPointer at all?
|
||||
// TODO Is TxWritePointer not sufficient enough?
|
||||
|
|
@ -487,12 +487,6 @@ impl<E> Udp<E> for (&mut ActiveW5500<'_, '_, '_, E>, &UdpSocket) {
|
|||
}
|
||||
|
||||
|
||||
fn u16_to_be_bytes(u16: u16) -> [u8; 2] {
|
||||
let mut bytes = [0u8; 2];
|
||||
BigEndian::write_u16(&mut bytes, u16);
|
||||
bytes
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum SocketRegister {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue