tangled
alpha
login
or
join now
sachy.dev
/
pico-strike
0
fork
atom
A RPi Pico powered Lightning Detector
0
fork
atom
overview
issues
pulls
pipelines
Reinstate alloc lock, clean read loop
sachy.dev
1 week ago
ae9e4eac
068f7f4d
+13
-12
3 changed files
expand all
collapse all
unified
split
src
allocator.rs
locks.rs
net
crypto.rs
+4
-2
src/allocator.rs
reviewed
···
3
3
ptr::NonNull,
4
4
};
5
5
6
6
-
use embassy_sync::blocking_mutex::{Mutex, raw::CriticalSectionRawMutex};
6
6
+
use embassy_sync::blocking_mutex::Mutex;
7
7
use rlsf::Tlsf;
8
8
use static_cell::ConstStaticCell;
9
9
+
10
10
+
use crate::locks::AllocatorLock;
9
11
10
12
type Heap = Tlsf<'static, usize, usize, { usize::BITS as usize }, { usize::BITS as usize }>;
11
13
···
14
16
}
15
17
16
18
pub struct PicoHeap<const MEMORY_SIZE: usize> {
17
17
-
inner: Mutex<CriticalSectionRawMutex, HeapInner>,
19
19
+
inner: Mutex<AllocatorLock, HeapInner>,
18
20
block: ConstStaticCell<[u8; MEMORY_SIZE]>,
19
21
}
20
22
+1
src/locks.rs
reviewed
···
1
1
use embassy_rp::spinlock_mutex::SpinlockRawMutex;
2
2
3
3
+
pub type AllocatorLock = SpinlockRawMutex<0>;
3
4
pub type RtcLock = SpinlockRawMutex<1>;
4
5
pub type ConnectionStatusLock = SpinlockRawMutex<2>;
5
6
pub type DataTransferLock = SpinlockRawMutex<3>;
+8
-10
src/net/crypto.rs
reviewed
···
2
2
use embassy_futures::select::{Either, select};
3
3
use embassy_net::tcp::{TcpReader, TcpSocket, TcpWriter};
4
4
use embedded_io_async::{Read, Write};
5
5
-
use sachy_fmt::{error, unwrap, warn};
5
5
+
use sachy_fmt::{error, unwrap};
6
6
use striker_proto::{Server, ServerBuilder, ServerReceiver, ServerSender};
7
7
8
8
use crate::{
···
43
43
.await
44
44
.map_err(|_| PicoError::CryptoProtoError)?;
45
45
46
46
-
if msg_size > 0
47
47
-
&& let Ok(req) = recv_state.decode_request(&mut msg_buf)
46
46
+
let req = recv_state.decode_request(&mut msg_buf)?;
47
47
+
48
48
+
if let Some((resp, resp_tx)) = RpcServer::handle_request(req)
49
49
+
.await
50
50
+
.zip(UpdateConnection::can_update())
48
51
{
49
49
-
let Some((resp, resp_tx)) = RpcServer::handle_request(req)
50
50
-
.await
51
51
-
.zip(UpdateConnection::can_update())
52
52
-
else {
53
53
-
warn!("Connection dropped before response");
54
54
-
break;
55
55
-
};
56
52
resp_tx.try_send(resp).ok();
53
53
+
} else {
54
54
+
break;
57
55
}
58
56
59
57
msg_buf.resize_with(4096, Default::default);