mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
examples: the beginnings of message passing and receiving
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
646cf9340e
commit
8b54ebff35
2 changed files with 28 additions and 2 deletions
|
|
@ -70,7 +70,9 @@ fn main() {
|
||||||
// println!("Unexpected return value: {:?}", heap);
|
// println!("Unexpected return value: {:?}", heap);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
println!("Starting server...");
|
||||||
let server_addr = xous::syscall::create_server(xous::make_name!("📜")).expect("couldn't create server");
|
let server_addr = xous::syscall::create_server(xous::make_name!("📜")).expect("couldn't create server");
|
||||||
|
println!("Server listening on address {:?}", server_addr);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
println!("Waiting for an event...");
|
println!("Waiting for an event...");
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,32 @@ fn main() {
|
||||||
|
|
||||||
timer::init();
|
timer::init();
|
||||||
|
|
||||||
|
let mut connection = None;
|
||||||
|
println!("Attempting to connect to server...");
|
||||||
|
while connection.is_none() {
|
||||||
|
if let Ok(cid) = xous::syscall::connect((3, 2626920432, 3, 2626920432)) {
|
||||||
|
connection = Some(cid);
|
||||||
|
} else {
|
||||||
|
xous::syscall::yield_slice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let connection = connection.unwrap();
|
||||||
|
println!("Connected: {:?}", connection);
|
||||||
|
|
||||||
|
let mut counter = 0;
|
||||||
loop {
|
loop {
|
||||||
println!("Waiting for an event...");
|
println!("Sending a message...");
|
||||||
xous::rsyscall(xous::SysCall::WaitEvent).expect("Couldn't call waitevent");
|
let result = xous::syscall::send_message(
|
||||||
|
connection,
|
||||||
|
xous::Message::Scalar(xous::ScalarMessage {
|
||||||
|
id: counter + 4096,
|
||||||
|
arg1: counter,
|
||||||
|
arg2: counter * 2,
|
||||||
|
arg3: !counter,
|
||||||
|
arg4: counter + 1,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.expect("couldn't send message");
|
||||||
|
counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue