User forums > Help

Ubuntu - Can't open serial port ttyUSB0 during debug

(1/2) > >>

meranges:
Hi,

I'm new developper with Code::Blocks (16.01 installed yesterday from Ubuntu application center) under Ubuntu 18.04.1 LTS (up to date)

I try to make a program which can reads on a serial port (/dev/ttyuSB0).

When I run the program without debbuging.
When I try to debug it, I can open the port I have an error message indication "Input/out Error"
The same application can be debugged under Rapian without problem

How to solve this issue ?

oBFusCATed:
Can you be more clear what the problem is? Your program fails when? When you single step? What happens if you debug it using command line gdb? Does it still fail? Debuggers change timing behaviour of programs, so if you have a timing bug then it is possible that the debugger is exaggerating it.

BlueHazzard:
you probably have to set the udev rules for your usb device
https://wiki.archlinux.org/index.php/Udev

meranges:
Thank you for your answer.

Yes of course, my access to the serial port is made by an ifstream object.
I can run in step by step mode or run with debugging my program, the program is waiting for a while and the port is not opened.
The perror message is "input/output Error"

Here is my code extracted from a small class

    ifstream SerialPort;
    SerialPort.open ("/dev/ttyUSB0");
    if (!SerialPort.is_open())
    {
        perror("can't open serial port");
        exit(1);
    }

I don't know how to debug with gdb command line but I have a warning indicating gdb failed to set controlling terminal. because it is not permitted

Hope it helps to solve this issue

oBFusCATed:

--- Quote from: meranges on February 10, 2019, 08:06:16 am ---I don't know how to debug with gdb command line but I have a warning indicating gdb failed to set controlling terminal. because it is not permitted

--- End quote ---
If you search about this warning you'll see that it is harmless and it is not related to your problem.

To debug with gdb just enable full debug log and you'll see all the commands executed by C::B.

Navigation

[0] Message Index

[#] Next page

Go to full version