Merge branch 'master' into feature/phy-reset
This commit is contained in:
commit
e4740ce1b5
|
@ -558,13 +558,15 @@ impl ProfileSerializer {
|
|||
/// * `channels` - A list of channels to apply the configuration to.
|
||||
/// * `ftw` - If provided, indicates a frequency tuning word for the channels.
|
||||
/// * `pow` - If provided, indicates a phase offset word for the channels.
|
||||
/// * `acr` - If provided, indicates the amplitude control register for the channels.
|
||||
/// * `acr` - If provided, indicates the amplitude control register for the channels. The ACR
|
||||
/// should be stored in the 3 LSB of the word. Note that if amplitude scaling is to be used,
|
||||
/// the "Amplitude multiplier enable" bit must be set.
|
||||
pub fn update_channels(
|
||||
&mut self,
|
||||
channels: &[Channel],
|
||||
ftw: Option<u32>,
|
||||
pow: Option<u16>,
|
||||
acr: Option<u16>,
|
||||
acr: Option<u32>,
|
||||
) {
|
||||
let mut csr: u8 = *0u8.set_bits(1..3, self.mode as u8);
|
||||
for channel in channels.iter() {
|
||||
|
@ -582,7 +584,7 @@ impl ProfileSerializer {
|
|||
}
|
||||
|
||||
if let Some(acr) = acr {
|
||||
self.add_write(Register::ACR, &acr.to_be_bytes());
|
||||
self.add_write(Register::ACR, &acr.to_be_bytes()[1..=3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,14 +608,14 @@ impl ProfileSerializer {
|
|||
// Pad the buffer to 32-bit alignment by adding dummy writes to CSR and LSRR.
|
||||
let padding = 4 - (self.index % 4);
|
||||
match padding {
|
||||
0 => {}
|
||||
1 => {
|
||||
// For a pad size of 1, we have to pad with 5 bytes to align things.
|
||||
self.add_write(Register::CSR, &[(self.mode as u8) << 1]);
|
||||
self.add_write(Register::LSRR, &[0, 0, 0]);
|
||||
self.add_write(Register::LSRR, &[0, 0]);
|
||||
}
|
||||
2 => self.add_write(Register::CSR, &[(self.mode as u8) << 1]),
|
||||
3 => self.add_write(Register::LSRR, &[0, 0, 0]),
|
||||
3 => self.add_write(Register::LSRR, &[0, 0]),
|
||||
4 => {}
|
||||
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
@ -22,4 +22,6 @@ python3 -m pip install -r requirements.txt
|
|||
ping -c 5 -w 20 stabilizer-hitl
|
||||
|
||||
# Test the MQTT interface.
|
||||
python3 miniconf.py dt/sinara/stabilizer afe/0 '"G2"'
|
||||
python3 miniconf.py dt/sinara/stabilizer afe/0='"G2"'
|
||||
python3 miniconf.py dt/sinara/stabilizer afe/0='"G1"' iir_ch/0/0=\
|
||||
'{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}'
|
||||
|
|
18
miniconf.py
18
miniconf.py
|
@ -83,8 +83,10 @@ class Miniconf:
|
|||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Miniconf command line interface.',
|
||||
epilog='''Example:
|
||||
%(prog)s -v -b mqtt dt/sinara/stabilizer afe/0 '"G10"'
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog='''Examples:
|
||||
%(prog)s dt/sinara/stabilizer afe/0='"G2"' iir_ch/0/0=\
|
||||
'{"y_min": -32767, "y_max": 32767, "y_offset": 0, "ba": [1.0, 0, 0, 0, 0]}'
|
||||
''')
|
||||
parser.add_argument('-v', '--verbose', action='count', default=0,
|
||||
help='Increase logging verbosity')
|
||||
|
@ -92,10 +94,8 @@ def main():
|
|||
help='The MQTT broker address')
|
||||
parser.add_argument('prefix', type=str,
|
||||
help='The MQTT topic prefix of the target')
|
||||
parser.add_argument('path', type=str,
|
||||
help='The setting path to configure')
|
||||
parser.add_argument('value', type=str,
|
||||
help='The value of setting in JSON format')
|
||||
parser.add_argument('settings', metavar="KEY=VALUE", nargs='+',
|
||||
help='JSON encoded values for settings path keys.')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -107,8 +107,10 @@ def main():
|
|||
|
||||
async def configure_settings():
|
||||
interface = await Miniconf.create(args.prefix, args.broker)
|
||||
response = await interface.command(args.path, json.loads(args.value))
|
||||
print(f"Response: {response}")
|
||||
for kv in args.settings:
|
||||
path, value = kv.split("=", 1)
|
||||
response = await interface.command(path, json.loads(value))
|
||||
print(response)
|
||||
|
||||
loop.run_until_complete(configure_settings())
|
||||
|
||||
|
|
|
@ -144,14 +144,15 @@ impl<'a> ProfileBuilder<'a> {
|
|||
/// * `channels` - A list of channels to apply the configuration to.
|
||||
/// * `ftw` - If provided, indicates a frequency tuning word for the channels.
|
||||
/// * `pow` - If provided, indicates a phase offset word for the channels.
|
||||
/// * `acr` - If provided, indicates the amplitude control register for the channels.
|
||||
/// * `acr` - If provided, indicates the amplitude control register for the channels. The
|
||||
/// 24-bits of the ACR should be stored in the last 3 LSB.
|
||||
#[allow(dead_code)]
|
||||
pub fn update_channels(
|
||||
mut self,
|
||||
channels: &[Channel],
|
||||
ftw: Option<u32>,
|
||||
pow: Option<u16>,
|
||||
acr: Option<u16>,
|
||||
acr: Option<u32>,
|
||||
) -> Self {
|
||||
self.serializer.update_channels(channels, ftw, pow, acr);
|
||||
self
|
||||
|
|
Loading…
Reference in New Issue