Code::Blocks Forums
User forums => Help => Topic started by: meranges on February 09, 2019, 01:25:06 pm
-
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 ?
-
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.
-
you probably have to set the udev rules for your usb device
https://wiki.archlinux.org/index.php/Udev
-
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
-
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
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.
-
I keep on my investigations.
It seems to be linked with the amount of data sended by the serial port. There is continously data on the serial port.
If I stop the stream , or I reduce it, all works fine.
I don't understand the link between the amount of data and this error even more beacause it woks fine on a small Raspberry Pi Zero.
-
The serial port has a limited character throughput (given by bauds/10). This is the same limit in a computer and in the Raspberry Pi Zero. The latter is relatively slow and (possibly) can't overflow the output buffer. The former is way faster and any buffer will overflow soon or later.
Are you checking if the calls to I/O functions are successful?. For example, fprintf() returns the number of characters really written: do this value match the number of characters you sent?.
-
I don't understand how serial ports work under Linux.
I keep on develop my C++ application. And I have no problem for a while.
I add some files, new class, into my project and it doesn'y works again. And now it is in Debug or release...
On open (SerialPortName.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
I get a negative value. If I display the status witha perror, i can have something like "Success" !!! or "input/Outut error", even if I don't change anything in my code !
I try to go back in my project, and I can find a version working fine every launches.
I try to add some of my new code but I don't call it The propblem appears...
Is anyone can help me to understand what is this ununderstandable problem ?
Is there a link with character ASCII or not ? are char always only 1 byte long ? or is it depending on ??? I don't know what.
-
You need to find a programming support site for your Operating System (OS).
http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
Edit: The above is true if the issue can be duplicated when running from the command [line] to verify the problem is not part of Code::Blocks. The others in this thread are likely to try to help you; but, if the problem is not in Code::Blocks there is a good chance they will not be able to help you.
Tim S.