mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Use set_no_reply(true) on certain messages
This commit is contained in:
@@ -57,8 +57,9 @@ impl AniMeDbusWriter {
|
|||||||
image[1][..7].copy_from_slice(&ANIME_PANE2_PREFIX);
|
image[1][..7].copy_from_slice(&ANIME_PANE2_PREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "AnimatrixWrite")?
|
let mut msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "AnimatrixWrite")?
|
||||||
.append2(image[0].to_vec(), image[1].to_vec());
|
.append2(image[0].to_vec(), image[1].to_vec());
|
||||||
|
msg.set_no_reply(true);
|
||||||
self.connection.send(msg).unwrap();
|
self.connection.send(msg).unwrap();
|
||||||
thread::sleep(Duration::from_millis(self.block_time));
|
thread::sleep(Duration::from_millis(self.block_time));
|
||||||
if self.stop.load(Ordering::Relaxed) {
|
if self.stop.load(Ordering::Relaxed) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ impl AuraDbusWriter {
|
|||||||
/// This method must always be called before the very first write to initialise
|
/// This method must always be called before the very first write to initialise
|
||||||
/// the keyboard LED EC in the correct mode
|
/// the keyboard LED EC in the correct mode
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn init_effect(&self) -> Result<(), Box<dyn Error>> {
|
pub fn init_effect(&self) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
let match_rule = dbus::message::MatchRule::new_signal(DBUS_IFACE, "LedCancelEffect");
|
let match_rule = dbus::message::MatchRule::new_signal(DBUS_IFACE, "LedCancelEffect");
|
||||||
let stopper = self.stop.clone();
|
let stopper = self.stop.clone();
|
||||||
self.connection
|
self.connection
|
||||||
@@ -46,8 +46,13 @@ impl AuraDbusWriter {
|
|||||||
|
|
||||||
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "LedWriteBytes")?
|
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "LedWriteBytes")?
|
||||||
.append1(KeyColourArray::get_init_msg());
|
.append1(KeyColourArray::get_init_msg());
|
||||||
self.connection.send(msg).unwrap();
|
let r = self
|
||||||
Ok(())
|
.connection
|
||||||
|
.send_with_reply_and_block(msg, Duration::from_millis(5000))?;
|
||||||
|
if let Some(reply) = r.get1::<&str>() {
|
||||||
|
return Ok(reply.to_owned());
|
||||||
|
}
|
||||||
|
Err(Box::new(dbus::Error::new_custom("name", "message")))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write a single colour block.
|
/// Write a single colour block.
|
||||||
@@ -62,11 +67,12 @@ impl AuraDbusWriter {
|
|||||||
// self.connection.process(Duration::from_micros(300))?;
|
// self.connection.process(Duration::from_micros(300))?;
|
||||||
|
|
||||||
let group = key_colour_array.get();
|
let group = key_colour_array.get();
|
||||||
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "LedWriteEffect")?
|
let mut msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "LedWriteEffect")?
|
||||||
.append3(&group[0].to_vec(), &group[1].to_vec(), &group[2].to_vec())
|
.append3(&group[0].to_vec(), &group[1].to_vec(), &group[2].to_vec())
|
||||||
.append3(&group[3].to_vec(), &group[4].to_vec(), &group[5].to_vec())
|
.append3(&group[3].to_vec(), &group[4].to_vec(), &group[5].to_vec())
|
||||||
.append3(&group[6].to_vec(), &group[7].to_vec(), &group[8].to_vec())
|
.append3(&group[6].to_vec(), &group[7].to_vec(), &group[8].to_vec())
|
||||||
.append2(&group[9].to_vec(), &group[10].to_vec());
|
.append2(&group[9].to_vec(), &group[10].to_vec());
|
||||||
|
msg.set_no_reply(true);
|
||||||
self.connection.send(msg).unwrap();
|
self.connection.send(msg).unwrap();
|
||||||
thread::sleep(Duration::from_micros(self.block_time));
|
thread::sleep(Duration::from_micros(self.block_time));
|
||||||
if self.stop.load(Ordering::Relaxed) {
|
if self.stop.load(Ordering::Relaxed) {
|
||||||
@@ -79,7 +85,7 @@ impl AuraDbusWriter {
|
|||||||
pub fn write_multizone(
|
pub fn write_multizone(
|
||||||
&mut self,
|
&mut self,
|
||||||
group: &[[u8; LED_MSG_LEN]; 4],
|
group: &[[u8; LED_MSG_LEN]; 4],
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
self.connection.process(Duration::from_micros(300))?;
|
self.connection.process(Duration::from_micros(300))?;
|
||||||
|
|
||||||
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "LedWriteMultizone")?
|
let msg = Message::new_method_call(DBUS_NAME, DBUS_PATH, DBUS_IFACE, "LedWriteMultizone")?
|
||||||
@@ -87,12 +93,13 @@ impl AuraDbusWriter {
|
|||||||
.append1(&group[1].to_vec())
|
.append1(&group[1].to_vec())
|
||||||
.append1(&group[2].to_vec())
|
.append1(&group[2].to_vec())
|
||||||
.append1(&group[3].to_vec());
|
.append1(&group[3].to_vec());
|
||||||
self.connection.send(msg).unwrap();
|
let r = self
|
||||||
thread::sleep(Duration::from_millis(self.block_time));
|
.connection
|
||||||
if self.stop.load(Ordering::Relaxed) {
|
.send_with_reply_and_block(msg, Duration::from_millis(5000))?;
|
||||||
panic!("Go signal to stop!");
|
if let Some(reply) = r.get1::<&str>() {
|
||||||
|
return Ok(reply.to_owned());
|
||||||
}
|
}
|
||||||
Ok(())
|
Err(Box::new(dbus::Error::new_custom("name", "message")))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
Reference in New Issue
Block a user