some general testing things

This commit is contained in:
David Lenfesty 2023-06-03 12:45:57 -06:00
parent 31d55f0186
commit 1abbe4ea97
5 changed files with 32 additions and 3 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.egg-info/ *.egg-info/
build/

View File

@ -1,7 +1,7 @@
MEMORY MEMORY
{ {
RAM : ORIGIN = 0x10000000, LENGTH = 64K RAM : ORIGIN = 0x10000000, LENGTH = 64K
FLASH : ORIGIN = 0x00000000, LENGTH = 64K FLASH : ORIGIN = 0x00000000, LENGTH = 80K
} }
REGION_ALIAS("REGION_TEXT", FLASH); REGION_ALIAS("REGION_TEXT", FLASH);

View File

@ -4,7 +4,7 @@ use crate::proto::{
serialize_response_error, serialize_response_value, PacketParser, ResponsePacket, Settings, ErrorCodes serialize_response_error, serialize_response_value, PacketParser, ResponsePacket, Settings, ErrorCodes
}; };
struct CommandInterface { pub struct CommandInterface {
parser: PacketParser, parser: PacketParser,
} }

View File

@ -15,11 +15,14 @@ use core::{
use embedded_hal::prelude::{_embedded_hal_blocking_i2c_Read, _embedded_hal_blocking_i2c_Write}; use embedded_hal::prelude::{_embedded_hal_blocking_i2c_Read, _embedded_hal_blocking_i2c_Write};
use mcp4726::Status; use mcp4726::Status;
use riscv_rt::entry; use riscv_rt::entry;
use smoltcp::socket::{Socket, self};
use smoltcp::wire::{IpAddress, Ipv4Address}; use smoltcp::wire::{IpAddress, Ipv4Address};
use smoltcp::{ use smoltcp::{
iface::{SocketSet, SocketStorage}, iface::{SocketSet, SocketStorage},
time::Instant, time::Instant,
wire::HardwareAddress, wire::HardwareAddress,
socket::tcp::Socket as TcpSocket,
socket::tcp::SocketBuffer,
}; };
mod eth; mod eth;
@ -98,6 +101,13 @@ fn main() -> ! {
let mut socket_storage = [SocketStorage::EMPTY; 4]; let mut socket_storage = [SocketStorage::EMPTY; 4];
let mut socket_set = SocketSet::new(&mut socket_storage[..]); let mut socket_set = SocketSet::new(&mut socket_storage[..]);
//let mut tx_storage = [0u8; 128];
//let mut rx_storage = [0u8; 128];
//let mut tx_buf = SocketBuffer::new(&mut tx_storage[..]);
//let mut rx_buf = SocketBuffer::new(&mut rx_storage[..]);
//let mut command_socket = socket_set.add(TcpSocket::new(tx_buf, rx_buf));
let mut last_blink: u32 = 0; let mut last_blink: u32 = 0;
let mut toggle = false; let mut toggle = false;
//defmt::info!("Done setup"); //defmt::info!("Done setup");
@ -120,6 +130,8 @@ fn main() -> ! {
//write_reg(0xf000_381c, 1u32); //write_reg(0xf000_381c, 1u32);
} }
//let mut cmd = command_interface::CommandInterface::new();
loop { loop {
let now = millis(); let now = millis();
if now - last_blink > 1000 { if now - last_blink > 1000 {
@ -132,6 +144,7 @@ fn main() -> ! {
} }
if iface.poll(Instant::from_millis(now), &mut device, &mut socket_set) { if iface.poll(Instant::from_millis(now), &mut device, &mut socket_set) {
//cmd.run(socket_set.get_mut(command_socket));
} }
handle_timer_event(); handle_timer_event();

View File

@ -1,2 +1,17 @@
IP = "192.168.88.69"
PORT = 2000
import socket
from .command_packets import CommandPacket, Settings, PacketParser
def main(): def main():
print("Hello world!") with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.connect((IP, PORT))
sock.send(CommandPacket(False, Settings.Gain, 125).serialize())
data = sock.recv(1024)
parser = PacketParser()
data, packet = parser.parse_bytearray(data)
if packet is not None:
print(packet)