Compare commits
No commits in common. "9852b326466f80a03000a42aa606334068aab09e" and "e13ed37271761e34ff3b417311e2407ab9e35e56" have entirely different histories.
9852b32646
...
e13ed37271
|
@ -100,7 +100,6 @@ pub enum ShowCommand {
|
||||||
Pid,
|
Pid,
|
||||||
SteinhartHart,
|
SteinhartHart,
|
||||||
PostFilter,
|
PostFilter,
|
||||||
Ipv4,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
@ -495,8 +494,6 @@ fn ipv4_addr(input: &[u8]) -> IResult<&[u8], Result<[u8; 4], Error>> {
|
||||||
|
|
||||||
fn ipv4(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
fn ipv4(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
||||||
let (input, _) = tag("ipv4")(input)?;
|
let (input, _) = tag("ipv4")(input)?;
|
||||||
alt((
|
|
||||||
|input| {
|
|
||||||
let (input, _) = whitespace(input)?;
|
let (input, _) = whitespace(input)?;
|
||||||
let (input, address) = ipv4_addr(input)?;
|
let (input, address) = ipv4_addr(input)?;
|
||||||
let (input, _) = tag("/")(input)?;
|
let (input, _) = tag("/")(input)?;
|
||||||
|
@ -518,9 +515,6 @@ fn ipv4(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
Ok((input, result()))
|
Ok((input, result()))
|
||||||
},
|
|
||||||
value(Ok(Command::Show(ShowCommand::Ipv4)), end),
|
|
||||||
))(input)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
fn command(input: &[u8]) -> IResult<&[u8], Result<Command, Error>> {
|
||||||
|
@ -585,12 +579,6 @@ mod test {
|
||||||
assert_eq!(command, Ok(Command::Save { channel: Some(0) }));
|
assert_eq!(command, Ok(Command::Save { channel: Some(0) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_show_ipv4() {
|
|
||||||
let command = Command::parse(b"ipv4");
|
|
||||||
assert_eq!(command, Ok(Command::Show(ShowCommand::Ipv4)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_ipv4() {
|
fn parse_ipv4() {
|
||||||
let command = Command::parse(b"ipv4 192.168.1.26/24");
|
let command = Command::parse(b"ipv4 192.168.1.26/24");
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -183,7 +183,7 @@ fn main() -> ! {
|
||||||
let hwaddr = EthernetAddress(eui48);
|
let hwaddr = EthernetAddress(eui48);
|
||||||
info!("EEPROM MAC address: {}", hwaddr);
|
info!("EEPROM MAC address: {}", hwaddr);
|
||||||
|
|
||||||
net::run(clocks, dp.ETHERNET_MAC, dp.ETHERNET_DMA, eth_pins, hwaddr, ipv4_config.clone(), |iface| {
|
net::run(clocks, dp.ETHERNET_MAC, dp.ETHERNET_DMA, eth_pins, hwaddr, ipv4_config, |iface| {
|
||||||
Server::<Session>::run(iface, |server| {
|
Server::<Session>::run(iface, |server| {
|
||||||
leds.r1.off();
|
leds.r1.off();
|
||||||
|
|
||||||
|
@ -280,12 +280,6 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::Show(ShowCommand::Ipv4) => {
|
|
||||||
let (cidr, gateway) = net::split_ipv4_config(ipv4_config.clone());
|
|
||||||
let _ = write!(socket, "{{\"addr\":\"{}\"", cidr);
|
|
||||||
gateway.map(|gateway| write!(socket, ",\"gateway\":\"{}\"", gateway));
|
|
||||||
let _ = writeln!(socket, "}}");
|
|
||||||
}
|
|
||||||
Command::PwmPid { channel } => {
|
Command::PwmPid { channel } => {
|
||||||
channels.channel_state(channel).pid_engaged = true;
|
channels.channel_state(channel).pid_engaged = true;
|
||||||
leds.g3.on();
|
leds.g3.on();
|
||||||
|
@ -447,11 +441,7 @@ fn main() -> ! {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply new IPv4 address/gateway
|
// Apply new IPv4 address/gateway
|
||||||
new_ipv4_config.take()
|
new_ipv4_config.map(|config| server.set_ipv4_config(config));
|
||||||
.map(|config| {
|
|
||||||
server.set_ipv4_config(config.clone());
|
|
||||||
ipv4_config = config;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update watchdog
|
// Update watchdog
|
||||||
wd.feed();
|
wd.feed();
|
||||||
|
|
Loading…
Reference in New Issue