Skip to content

Commit

Permalink
build: parser: Fix: Ping360 transducer reuturn type
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Jul 29, 2024
1 parent fb25348 commit 922c9f7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions build/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ impl MessageDefinition {

let function_token = match self.category {
MessageDefinitionCategory::Set | MessageDefinitionCategory::Control => {
let mut result_type = quote! { () };
let result = if self.category == MessageDefinitionCategory::Set {
quote! {
let receiver = self.subscribe();
Expand All @@ -245,18 +246,30 @@ impl MessageDefinition {
self.wait_for_ack(receiver, #struct_name::id()).await
}
} else {
quote! {
self.get_common().send_message(package).await?;
// Special case where Ping360's config Transducer method returns a DeviceDataStruct
if self.id == 2601 {
result_type = quote! { DeviceDataStruct };
quote! {
let receiver = self.subscribe();

Ok(())
self.get_common().send_message(package).await?;

self.wait_for_message(receiver).await
}
} else {
quote! {
self.get_common().send_message(package).await?;

Ok(())
}
}
};

quote! {
#[doc = #function_description]
#[doc = "# Arguments"]
#(#function_parameters_description)*
pub async fn #function_name(&self, #(#function_parameters),*) -> Result<(), PingError> {
pub async fn #function_name(&self, #(#function_parameters),*) -> Result<#result_type, PingError> {
let request = Messages::#pascal_message_name(#struct_name {
#(#function_assignments,)*
});
Expand Down

0 comments on commit 922c9f7

Please sign in to comment.