Fix bugs in C++ software

This commit is contained in:
Joris van Rantwijk 2024-09-19 22:48:46 +02:00
parent f5d027cecc
commit 30939214df
3 changed files with 9 additions and 9 deletions

View File

@ -56,10 +56,10 @@ void show_status(puzzlefw::PuzzleFwDevice& device)
printf(" acquisition = %s\n",
device.is_acquisition_enabled() ? "on" : "off");
printf(" channel mode = %d channels",
printf(" channel mode = %d channels\n",
device.is_4channel_mode() ? 4 : 2);
printf(" trigger mode = %s, channel=%u, edge=%s\n",
printf(" trigger mode = %s, ch=%u, edge=%s\n",
trigger_mode_to_string(device.get_trigger_mode()).c_str(),
device.get_trigger_ext_channel(),
device.get_trigger_ext_falling() ? "falling" : "rising");
@ -71,7 +71,7 @@ void show_status(puzzlefw::PuzzleFwDevice& device)
device.get_record_length());
unsigned int divisor = device.get_decimation_factor();
printf(" rate divisor = %u, sample rate = %u Sa/s\n",
printf(" rate divisor = %u (%u Sa/s)\n",
divisor, 125000000 / divisor);
printf(" averaging = %s\n",
@ -88,13 +88,13 @@ void show_status(puzzlefw::PuzzleFwDevice& device)
if (device.is_digital_simulation_enabled()) {
uint32_t simulation_state = device.get_digital_simulation_state();
printf(" digital simulation = %u %u %u %u\n",
printf(" digital sim = %u %u %u %u\n",
simulation_state & 1,
(simulation_state >> 1) & 1,
(simulation_state >> 2) & 1,
(simulation_state >> 3) & 1);
} else {
printf(" digital simulation = off\n");
printf(" digital sim = off\n");
}
uint32_t dma_status = device.get_dma_status();

View File

@ -36,7 +36,8 @@ static std::string find_puzzlefw_device_name()
// Find entry matching "*.puzzlefw" in /sys filesystem.
for (const auto& entry : fs::directory_iterator(SOC_DEVICES_DIR)) {
std::string fname = entry.path().filename().string();
if (fname.compare(fname.size() - 9, 9, ".puzzlefw") == 0) {
if (fname.size() > 9
&& fname.compare(fname.size() - 9, 9, ".puzzlefw") == 0) {
return fname;
}
}

View File

@ -202,7 +202,6 @@ public:
/** Return the number of analog channels (2 or 4). */
unsigned int get_analog_channel_count()
{
// TODO -- modify firmware to add ch4-support bit
uint32_t v = read_reg(REG_CH4_MODE);
return (v & 0x100) ? 4 : 2;
}