psieg / Lightpack

Lightpack and Prismatik open repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change serial port from settings UI?

irfan798 opened this issue · comments

Sometimes my usb serial port name changes after reboot and sleep.

Is it possible to change serial port on settings without executing wizard?

Currently i can solve the issue my changing SerialPort configuration under main.conf and then restarting the Prismatik


It seems we have the function to change it, but it is only called from wizard:

void Settings::setAdalightSerialPortName(const QString & port)
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO;
setValueMain(Main::Key::Adalight::Port, port);
emit m_this->adalightSerialPortNameChanged(port);

else if (deviceName.compare(QStringLiteral("adalight"), Qt::CaseInsensitive) == 0) {
devType = SupportedDevices::DeviceTypeAdalight;
Settings::setAdalightSerialPortName(field(QStringLiteral("serialPort")).toString());
Settings::setAdalightSerialPortBaudRate(field(QStringLiteral("baudRate")).toString());
Settings::setColorSequence(devType, field(QStringLiteral("colorFormat")).toString());

But it seems like all the dynamic settings about port were commented out:

void LightpackApplication::startLedDeviceManager()
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO;
m_ledDeviceManager = new LedDeviceManager();
m_ledDeviceManagerThread = new QThread();
// connect(settings(), &Settings::connectedDeviceChanged, this, &LightpackApplication::handleConnectedDeviceChange, Qt::DirectConnection);
// connect(settings(), &Settings::adalightSerialPortNameChanged, m_ledDeviceManager, &LedDeviceManager::recreateLedDevice, Qt::DirectConnection);
// connect(settings(), &Settings::adalightSerialPortBaudRateChanged, m_ledDeviceManager, &LedDeviceManager::recreateLedDevice, Qt::DirectConnection);
// connect(m_settingsWindow, &SettingsWindow::updateLedsColors, m_ledDeviceManager, &LedDeviceManager::setColors, Qt::QueuedConnection);
m_pluginInterface = new LightpackPluginInterface(NULL);

m_AdalightDevice->setPortName(m_portName);// Settings::getAdalightSerialPortName());

It seems it is only possible to change when creating a new LedDeviceAdalight();

Was there a reason to comment those slots?
How can we activate them again, do they cause spesific bugs?

Not sure why there were commented out. I guess most of the work would be in creating the UI to set this outside the wizard.

Why do you need to change your serial port this often?

I have several USB's connected
And somehow they change /dev/ttyUSB0 to /dev/ttyUSB1 or vice versa on reboots and waking from sleep.
Also on re-plugging.
I dont know if this is a general case or just somehow an edge case.
Btw i am using Arduino Nano to control the leds.

I just figured it was reading the port information from main.conf while reading the source code.
I can manage with it now (chaging the port then restarting prismatik), but it would be great if we can just change it from Device screen, just a text input next to Run configuration wizard

image

I will try to uncomment those lines and add a textbox when i have time.

have you tried /dev/serial/by-id/... or /dev/serial/by-path/... instead of /dev/tty.. ? those might be less likely to change
you can also try udev rules for arduino