Adding functional prototype

This commit is contained in:
Ryan Summers 2021-05-31 14:06:02 +02:00
parent 5e2d2beeac
commit 04f61db6f2
3 changed files with 12 additions and 11 deletions

2
Cargo.lock generated
View File

@ -752,7 +752,7 @@ dependencies = [
[[package]]
name = "smoltcp-nal"
version = "0.1.0"
source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/udp-support#d387c79df56ba61af233846dbae3ae3bff601309"
source = "git+https://github.com/quartiq/smoltcp-nal.git?branch=feature/udp-support#bd90e9d1352e17cd0cc5406ea1d7a35be5761866"
dependencies = [
"embedded-nal",
"heapless 0.7.1",

View File

@ -17,7 +17,7 @@ use super::{
DigitalInput0, DigitalInput1, EthernetPhy, NetworkStack, AFE0, AFE1,
};
const NUM_TCP_SOCKETS: usize = 5;
const NUM_TCP_SOCKETS: usize = 4;
const NUM_UDP_SOCKETS: usize = 1;
const NUM_SOCKETS: usize = NUM_UDP_SOCKETS + NUM_TCP_SOCKETS;
@ -42,7 +42,7 @@ pub struct NetStorage {
pub struct UdpSocketStorage {
rx_storage: [u8; 1024],
tx_storage: [u8; 1024],
tx_storage: [u8; 2048],
tx_metadata: [smoltcp::storage::PacketMetadata<smoltcp::wire::IpEndpoint>; 10],
rx_metadata: [smoltcp::storage::PacketMetadata<smoltcp::wire::IpEndpoint>; 10],
}
@ -51,7 +51,7 @@ impl UdpSocketStorage {
const fn new() -> Self {
Self {
rx_storage: [0; 1024],
tx_storage: [0; 1024],
tx_storage: [0; 2048],
tx_metadata: [smoltcp::storage::PacketMetadata::<smoltcp::wire::IpEndpoint>::EMPTY; 10],
rx_metadata: [smoltcp::storage::PacketMetadata::<smoltcp::wire::IpEndpoint>::EMPTY; 10],
}
@ -82,7 +82,7 @@ impl NetStorage {
)],
neighbor_cache: [None; 8],
routes_cache: [None; 8],
sockets: [None, None, None, None, None, None, None],
sockets: [None, None, None, None, None, None],
tcp_socket_storage: [TcpSocketStorage::new(); NUM_TCP_SOCKETS],
udp_socket_storage: [UdpSocketStorage::new(); NUM_UDP_SOCKETS],
dhcp_tx_storage: [0; 600],

View File

@ -10,7 +10,7 @@ use crate::hardware::design_parameters::SAMPLE_BUFFER_SIZE;
// The number of data blocks that we will buffer in the queue.
const BLOCK_BUFFER_SIZE: usize = 30;
const SUBSAMPLE_RATE: usize = 2;
const SUBSAMPLE_RATE: usize = 1;
pub fn setup_streaming(
stack: NetworkReference,
@ -96,9 +96,9 @@ impl BlockGenerator {
self.current_id = self.current_id.wrapping_add(1);
// Note(unwrap): The buffering of the queue and processing of blocks must be fast enough
// such that blocks will never be silently dropped.
self.queue.enqueue(block).unwrap();
// Note: We silently ignore dropped blocks here. The queue can fill up if the service
// routing isn't being called often enough.
self.queue.enqueue(block).ok();
}
}
@ -173,7 +173,6 @@ impl DataStream {
_ => ()
})?;
// TODO: How should we handle a connection failure?
self.stack.connect(&mut socket, remote).unwrap();
// Note(unwrap): The socket will be empty before we replace it.
@ -211,7 +210,9 @@ impl DataStream {
if self.queue.ready() {
let mut handle = self.socket.borrow_mut().unwrap();
let capacity = self.stack.lock(|stack| stack.get_remaining_send_buffer(handle.handle)).unwrap();
let capacity = self.stack.lock(|stack| stack.with_udp_socket(handle, |socket| {
socket.payload_send_capacity()
})).unwrap();
let data = serialize_blocks(&mut self.buffer, capacity, &mut self.queue);