Commit 35b0e934 authored by Jussi Lindgren's avatar Jussi Lindgren

Drivers: Small fixes to gtec usbamp Linux driver

- Sampling rate didn't seem to persist across AS startups
- Fixed digital channel count increasing on each playback
parent ff8b5cf0
......@@ -99,7 +99,7 @@ void CConfigurationGTecGUSBampLinux::UpdateFilters(void)
gt_size l_ui32SampleRate = (gt_size)strtol(gtk_combo_box_get_active_text(l_pComboBoxSamplingFrequency),NULL,10);
// This takes a while so we'll keep the user informed via the console - might have to put this in a thread at some point though
m_rDriverContext.getLogManager() << LogLevel_Info << "Opening device...\n";
m_rDriverContext.getLogManager() << LogLevel_Info << "Opening device [" << l_pDeviceName << "] to query filters ...\n";
// Try opening the device
if(GT_OpenDevice(l_pDeviceName))
......@@ -404,7 +404,7 @@ void CConfigurationGTecGUSBampLinux::OnButtonCheckImpedanceClicked()
char* l_pDeviceName = gtk_combo_box_get_active_text(l_pComboBoxDevice);
// This takes a while so we'll keep the user informed via the console - might have to put this in a thread at some point though
m_rDriverContext.getLogManager() << LogLevel_Info << "Opening device...\n";
m_rDriverContext.getLogManager() << LogLevel_Info << "Opening device [" << l_pDeviceName << "] for impedance check ...\n";
// Try opening the device
if(GT_OpenDevice(l_pDeviceName))
......@@ -595,7 +595,6 @@ boolean CConfigurationGTecGUSBampLinux::postConfigure(void)
m_pConfig->bandpass[i] = l_ui32Value;
}
}
if(!CConfigurationBuilder::postConfigure()) // normal header is filled (Subject ID, Age, Gender, channels, sampling frequency), ressources are realesed
return false;
......
......@@ -24,6 +24,7 @@ CDriverGTecGUSBampLinux::CDriverGTecGUSBampLinux(IDriverContext& rDriverContext)
m_ui32CurrentSample(0),
m_ui32CurrentChannel(0)
{
// Default values
m_oHeader.setSamplingFrequency(512);
m_oHeader.setChannelCount(16);
......@@ -37,9 +38,6 @@ CDriverGTecGUSBampLinux::CDriverGTecGUSBampLinux(IDriverContext& rDriverContext)
m_oAnalogOutConfig.amplitude = 0;
m_oAnalogOutConfig.offset = 0;
// Set the sampling rate
m_oConfig.sample_rate = 512;
// This pretty much has to be GT_NOS_AUTOSET, don't know why, so says the documentation
m_oConfig.number_of_scans = GT_NOS_AUTOSET;
// Disable the trigger line, digital io scan, slave mode and the shortcut
......@@ -48,9 +46,6 @@ CDriverGTecGUSBampLinux::CDriverGTecGUSBampLinux(IDriverContext& rDriverContext)
// Set the mode to just take readings
m_oConfig.mode = GT_MODE_NORMAL;
// Number of channels to read from
m_oConfig.num_analog_in = m_oHeader.getChannelCount();
// Set all the blocks A-D to use the common ground and reference voltages
for (unsigned int i = 0; i < GT_USBAMP_NUM_GROUND; i++)
{
......@@ -59,7 +54,7 @@ CDriverGTecGUSBampLinux::CDriverGTecGUSBampLinux(IDriverContext& rDriverContext)
}
// Configure each input
for (unsigned char i = 0; i < m_oConfig.num_analog_in; i++)
for (unsigned char i = 0; i < GT_USBAMP_NUM_ANALOG_IN; i++)
{
// Should be from 1 - 16, specifies which channel to observe as input i
m_oConfig.analog_in_channel[i] = i + 1;
......@@ -112,7 +107,7 @@ CDriverGTecGUSBampLinux::CDriverGTecGUSBampLinux(IDriverContext& rDriverContext)
}
// Configure each input
for (unsigned int i = 0; i < m_oConfig.num_analog_in; i++)
for (unsigned int i = 0; i < GT_USBAMP_NUM_ANALOG_IN; i++)
{
stringstream l_oBandpassConfigName, l_oNotchConfigName, l_oBipolarConfigName;
l_oBandpassConfigName << "Bandpass" << i;
......@@ -123,7 +118,15 @@ CDriverGTecGUSBampLinux::CDriverGTecGUSBampLinux(IDriverContext& rDriverContext)
m_oSettings.add(l_oBipolarConfigName.str().c_str(), (int*)&m_oConfig.bipolar[i]);
}
m_oSettings.load();
// This restores saved settings if any, such as sampling rate
m_oSettings.load();
// Set the sampling rate that may have been changed by load
m_oConfig.sample_rate = m_oHeader.getSamplingFrequency();
// Number of channels that may have been changed by load
m_oConfig.num_analog_in = m_oHeader.getChannelCount();
}
CDriverGTecGUSBampLinux::~CDriverGTecGUSBampLinux(void)
......@@ -146,7 +149,8 @@ boolean CDriverGTecGUSBampLinux::initialize(const uint32 ui32SampleCountPerSentB
// If the scan digital inputs flag is set, the API will return one extra channel outside of the analog data requested, so we need to match that on the header
if(m_oConfig.scan_dio == GT_TRUE)
{
m_oHeader.setChannelCount(m_oHeader.getChannelCount() + 1);
m_oHeader.setChannelCount(m_oConfig.num_analog_in + 1);
m_oHeader.setChannelName(m_oConfig.num_analog_in, "Digital");
}
// Allocate buffers for...
......@@ -321,7 +325,10 @@ boolean CDriverGTecGUSBampLinux::configure(void)
return false;
}
m_oSettings.save();
m_oHeader.setChannelCount(m_oConfig.num_analog_in);
m_oHeader.setSamplingFrequency(m_oConfig.sample_rate);
m_oSettings.save();
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment