Commit Graph

50 Commits

Author SHA1 Message Date
232a08f110 nal: Fix comments & styling 2021-03-17 10:21:18 +08:00
2eadb652ff nal: Fix infinite loop when TX buffer is full
* For example, if the PHY linkup is down, instead of looping until resumption of the linkup, a write operation now closes the socket for re-connection in the future
2021-03-16 10:25:23 +08:00
6de19f43cc nal: Prevent pushing duplicate handles for the same TcpSocket 2021-03-12 12:36:30 +08:00
66c3aa534f nal: socket (TcpSocket) → handle; internal_socket → socket 2021-03-12 11:26:07 +08:00
99899e6657 nal: Fix read/write not pushing erroneous socket back to the stack
* Based on quartiq's minimq as of 933687c2e4
* In minimq applications, a socket is expected to be returned when `nal::TcpStack::open()` is called
  * `MqttClient::read()`/`write()` takes away the TCP socket handle (wrapped as an `Option`) from its `RefCell`, and then calls `nal::TcpStack::read()`/`write()`; if NAL returns `nb::Error`, then the MQTT client will propagate and return the error, leaving `None` behind
  * Afterwards, when `MqttClient::socket_is_connected()` gets called (e.g. while polling the interface), it will detect that the socket handle is `None`, and attempt to call `nal::TcpStack::open()`
  * Since `open()` pops a socket from the array (`unused_handles`), when implementing this NAL the socket should have been pushed back to the stack, i.e. by `close()`; this prevents any future calls of `open()` from returning `NetworkError::NoSocket` due to emptiness of the array of socket handles
2021-03-11 17:32:44 +08:00
d9e50bbcb6 nal: Prevent looping until the stack successfully connects to remote
* `NetworkStack::connect()`:
  * Add timeout for connection attempt
  * Now returns the socket at TCP ESTABLISHED or CLOSED states, or after connection timeout
* Split `NetworkStack::update()` into `update()` (for controlling the clock) and `poll()` (for polling the smoltcp EthernetInterface)
* Also remove option `auto_time_update`; the main application is responsible for what values `embedded_time::clock::Clock::try_now()` should return
2021-03-05 14:52:57 +08:00
6506562c3a cargo: fix [package] meta 2021-01-28 17:56:14 +08:00
3d471bff0a cargo: cleanup features 2021-01-28 17:56:13 +08:00
b6d1b3828a feature: add nal support 2021-01-26 17:21:53 +08:00
8da639b89d cargo: bump smoltcp version 2021-01-26 15:41:16 +08:00
6021623813 lib: add write mac 2021-01-25 18:32:21 +08:00
1add94c12e Remove cortex-m dependencies for delay (#2)
Co-Authored-By: occheung <dc@m-labs.hk>
Co-Committed-By: occheung <dc@m-labs.hk>
2021-01-25 12:35:23 +08:00
1ce193b8aa add gitignore 2021-01-20 15:26:48 +08:00
04ca484ded remove Cargo lockfile (this is a library) 2021-01-20 15:26:39 +08:00
01030f16a8 bump version 2021-01-20 15:22:24 +08:00
26dabd4dc0 spi: add CS delay 2021-01-18 15:33:27 +08:00
c4b62cc238 lib: derive debug for error for unwrapping 2021-01-18 15:33:03 +08:00
356c3aefe2 lib: reduce stack usage 2021-01-18 15:32:32 +08:00
2ca717c94f add license 2021-01-18 13:21:52 +08:00
d70937f053 update repo url 2021-01-18 13:16:58 +08:00
d358103664 Fix controller & smoltcp device bugs
* lib.rs: fix transmission status checking (line 176)
* lib.rs: make RAW_FRAME_LENGTH_MAX the same for both RX and TX, for the purpose of setting MAMXFL in controller, as well as setting MTU for smoltcp device
* smoltcp_phy.rs: fix missing MTU definition
2020-12-30 17:06:50 +08:00
010be3e9eb Fix controller & smoltcp device bugs
* lib.rs: fix transmission status checking (line 176)
* lib.rs: make RAW_FRAME_LENGTH_MAX the same for both RX and TX, for the purpose of setting MAMXFL in controller, as well as setting MTU for smoltcp device
* smoltcp_phy.rs: fix missing MTU definition
2020-12-30 17:05:39 +08:00
15b08c780e nix/itm-tools.nix: Fix hash for nixpkgs 20.09 2020-12-29 17:39:10 +08:00
0b91d5d1b9 Cargo.toml: Tidy & simplify 2020-12-29 17:03:12 +08:00
f68d5a8c93 Cargo.toml: Tidy & simplify 2020-12-29 16:58:58 +08:00
eeea973f1f Cargo.toml: Fix excessive dependency requirements 2020-12-29 11:53:34 +08:00
50c3003210 examples/tcp_stm32f407.rs: Use SysTick timer 2020-12-29 11:53:33 +08:00
362cf3c411 Use RTIC framework on the examples
* tcp_stm32f407 no longer obtains IP address from environment variables.
2020-12-29 11:47:02 +08:00
25e682763c Use core::cell::RefCell to refer to EthController 2020-12-29 11:43:55 +08:00
4ba5052623 Simplify, styling & spelling 2020-12-29 11:42:31 +08:00
e9a3a5e550 Add software delays on controller init; add missing SPISEL delay 2020-12-28 17:17:01 +08:00
ae0d77cbf1 Fix poor & unimplemented code 2020-12-28 17:06:31 +08:00
6b47c05843 nix/tmux.sh: Remove error message about existing tmux sessions 2020-12-09 10:51:32 +08:00
f029b9c267 Update README for updated instructions 2020-08-24 12:47:35 +08:00
7b313292ca Replace stm32f4xx_hal with embedded_hal in the library 2020-08-24 12:07:45 +08:00
8e8d14b901 Use japaric/itm-tools; Introduce tmux environment 2020-08-24 12:05:49 +08:00
b38c5ae65b Update README for clarification 2020-08-18 14:14:33 +08:00
5b99525cd0 Reorganise spi consts 2020-08-17 15:51:25 +08:00
755a77050e Fix nix-shell & itm 2020-06-26 13:47:52 +08:00
03b7e65a93 Update README 2020-06-24 16:24:33 +08:00
d399ebc3df Add nix-shell for Rust with OpenOCD & ITM; tcp example IP can be changed
* The user can now run a Nix shell to run the examples, OpenOCD and `itmdump` with Shell script binaries; use `run-help` for the list of these binaries.
* This includes a `itmdump` v0.3.1 binary re-compiled with patches for Rust >=1.41.0.
2020-06-24 15:38:57 +08:00
66f89e8085 Update tx_stm32f407, tcp_stm32f407 examples 2020-06-24 14:17:09 +08:00
e1c0b0dd23 Add tcp_stm32f407 example 2020-06-24 14:17:09 +08:00
dd062723a3 Add smoltcp Phy impls 2020-06-24 14:17:07 +08:00
5deab5db9b Fix MAC address ordering 2020-06-24 11:11:21 +08:00
6b9f58a98f Add tx_stm32f407 example 2020-06-18 15:06:55 +08:00
82f4bef09f Add packet TX 2020-06-18 11:09:39 +08:00
9b48a585cf Add packet RX 2020-06-17 17:04:18 +08:00
4e4267e55a Add reading SFR registers via SPI
* uses stm32f4xx_hal crate
2020-06-15 16:18:34 +08:00
5479912ab0 Initial commit 2020-06-15 15:39:00 +08:00