fixed open device bug

main
Tom Early 4 years ago
parent 9c85758c92
commit c0626fec23

@ -153,10 +153,12 @@ bool CController::InitDevices()
} }
//initialize each device //initialize each device
for (const auto &it : deviceset) while (! deviceset.empty())
{ {
if (dstar_device.OpenDevice(it.first, it.second, 921600)) dstar_device.OpenDevice(deviceset.front().first, deviceset.front().second, 921600);
return true; deviceset.pop_front();
dmr_device.OpenDevice(deviceset.front().first, deviceset.front().second, 921600);
deviceset.pop_front();
} }
// and start them up! // and start them up!

@ -175,43 +175,56 @@ bool CDV3003::OpenDevice(const std::string &serialno, const std::string &desc, i
status = FT_SetRts(ftHandle); status = FT_SetRts(ftHandle);
if (status != FT_OK) if (status != FT_OK)
{ {
FTDI_Error((char *)"FT_SetRts", status); FTDI_Error("FT_SetRts", status);
return true; return true;
} }
if (std::string::npos == description.find("DF2ET"))
{
//for usb-3012 pull DTR high to take AMBE3003 out of reset. //for usb-3012 pull DTR high to take AMBE3003 out of reset.
//for other devices noting is connected to DTR so it is a dont care //for other devices noting is connected to DTR so it is a dont care
status = FT_ClrDtr(ftHandle); status = FT_ClrDtr(ftHandle);
if (status != FT_OK) if (status != FT_OK)
{ {
FTDI_Error((char *)"FT_ClrDtr", status); FTDI_Error("FT_ClrDtr", status);
return true; return true;
} }
}
else
{
// for DF2ET-3003 interface pull DTR low to take AMBE3003 out of reset.
status = FT_SetDtr(ftHandle);
std::this_thread::sleep_for(std::chrono::milliseconds(50));
if (FT_OK != status) {
FTDI_Error("FT_SetDtr", status);
return false;
}
}
status = FT_SetBaudRate(ftHandle, baudrate ); status = FT_SetBaudRate(ftHandle, baudrate );
if (status != FT_OK) if (status != FT_OK)
{ {
FTDI_Error((char *)"FT_SetBaudRate", status); FTDI_Error("FT_SetBaudRate", status);
return false; return false;
} }
status = FT_SetLatencyTimer(ftHandle, 4); status = FT_SetLatencyTimer(ftHandle, 4);
if (status != FT_OK) if (status != FT_OK)
{ {
FTDI_Error((char *)"FT_SetLatencyTimer", status); FTDI_Error("FT_SetLatencyTimer", status);
return true; return true;
} }
status = FT_SetUSBParameters(ftHandle, USB3XXX_MAXPACKETSIZE, 0); status = FT_SetUSBParameters(ftHandle, USB3XXX_MAXPACKETSIZE, 0);
if (status != FT_OK){ if (status != FT_OK){
FTDI_Error((char *)"FT_SetUSBParameters", status); FTDI_Error("FT_SetUSBParameters", status);
return true; return true;
} }
status = FT_SetTimeouts(ftHandle, 200, 200 ); status = FT_SetTimeouts(ftHandle, 200, 200 );
if (status != FT_OK) if (status != FT_OK)
{ {
FTDI_Error((char *)"FT_SetTimeouts", status); FTDI_Error("FT_SetTimeouts", status);
return false; return false;
} }
@ -544,8 +557,11 @@ void CDV3003::ReadDevice()
{ {
while (keep_running) while (keep_running)
{ {
CTimer timer;
dv3003_packet p; dv3003_packet p;
if (! GetResponse(p)) if (GetResponse(p))
std::cout << "Timer is " << timer.time() * 1000.0 << " ms" << std::endl;
else
{ {
unsigned int channel = p.field_id - PKT_CHANNEL0; unsigned int channel = p.field_id - PKT_CHANNEL0;
auto packet = waiting_packet[channel].pop(); auto packet = waiting_packet[channel].pop();

Loading…
Cancel
Save

Powered by TurnKey Linux.