@@ -11,7 +11,7 @@ use byteorder::{BigEndian, ByteOrder};
1111/// A Modbus function code.
1212///
1313/// It is represented by an unsigned 8 bit integer.
14- #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
14+ #[ cfg_attr( all ( feature = "defmt" , target_os = "none" ) , derive( defmt:: Format ) ) ]
1515#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
1616pub enum FunctionCode {
1717 /// Modbus Function Code: `01` (`0x01`).
@@ -158,7 +158,7 @@ pub(crate) type Quantity = u16;
158158type RawData < ' r > = & ' r [ u8 ] ;
159159
160160/// A request represents a message from the client (master) to the server (slave).
161- #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
161+ #[ cfg_attr( all ( feature = "defmt" , target_os = "none" ) , derive( defmt:: Format ) ) ]
162162#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
163163pub enum Request < ' r > {
164164 ReadCoils ( Address , Quantity ) ,
@@ -193,20 +193,20 @@ pub enum Request<'r> {
193193}
194194
195195/// A server (slave) exception response.
196- #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
196+ #[ cfg_attr( all ( feature = "defmt" , target_os = "none" ) , derive( defmt:: Format ) ) ]
197197#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
198198pub struct ExceptionResponse {
199199 pub function : FunctionCode ,
200200 pub exception : Exception ,
201201}
202202
203203/// Represents a message from the client (slave) to the server (master).
204- #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
204+ #[ cfg_attr( all ( feature = "defmt" , target_os = "none" ) , derive( defmt:: Format ) ) ]
205205#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
206206pub struct RequestPdu < ' r > ( pub Request < ' r > ) ;
207207
208208/// Represents a message from the server (slave) to the client (master).
209- #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
209+ #[ cfg_attr( all ( feature = "defmt" , target_os = "none" ) , derive( defmt:: Format ) ) ]
210210#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
211211pub struct ResponsePdu < ' r > ( pub Result < Response < ' r > , ExceptionResponse > ) ;
212212
@@ -218,7 +218,7 @@ type EventCount = u16;
218218type MessageCount = u16 ;
219219
220220/// The response data of a successfull request.
221- #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
221+ #[ cfg_attr( all ( feature = "defmt" , target_os = "none" ) , derive( defmt:: Format ) ) ]
222222#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
223223pub enum Response < ' r > {
224224 ReadCoils ( Coils < ' r > ) ,
@@ -345,7 +345,7 @@ impl fmt::Display for Exception {
345345 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result { write ! ( f, "{}" , self . get_name( ) ) }
346346}
347347
348- #[ cfg( feature = "defmt" ) ]
348+ #[ cfg( all ( feature = "defmt" , target_os = "none" ) ) ]
349349impl defmt:: Format for Exception {
350350 fn format ( & self , fmt : defmt:: Formatter ) { defmt:: write!( fmt, "{}" , self . get_name( ) ) }
351351}
0 commit comments