Bug 101575 - First four characters of serial device munged on open
Summary: First four characters of serial device munged on open
Status: RESOLVED FIXED
Alias: None
Product: kandy
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Cornelius Schumacher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-15 20:33 UTC by Daniel Bohling
Modified: 2006-07-20 14:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bohling 2005-03-15 20:33:29 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.4.3 20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0, pie-8.7.7) 
OS:                Linux

For some reason kandy is munging the first four characters of the serial device
name when attempting to open for reading:

Error Message (Dialog box):
Unable to open device '@ " /ttyUSB0'. Please check that you have sufficient permissions.

Strace:
close(10)                               = 0
open("@^B\/ttyUSB0", O_RDWR|O_NONBLOCK|O_NOCTTY|O_LARGEFILE) = -1 ENOENT (No su
ch file or directory)
uname({sys="Linux", node="xxxxx", ...}) = 0
ioctl(5, FIONREAD, [1])                 = 0
ioctl(5, FIONREAD, [1])                 = 0
ioctl(5, FIONREAD, [1])                 = 0
ioctl(5, FIONREAD, [1])                 = 0
ioctl(5, FIONREAD, [1])                 = 0
ioctl(5, FIONREAD, [1])                 = 0


Config:
cat .kde/share/config/kandyrc
[General]
CurrentProfile=/usr/kde/3.4/share/apps/kandy/default.kandy

[MainWindow]
Height 1200=631
Width 1600=777

[Serial Port]
Baud Rate=57600
Serial Device=/dev/ttyUSB0
StartupModem=true
Comment 1 Terényi, Balázs 2005-04-06 09:27:13 UTC
The same here
Comment 2 Gideon Guillen 2005-07-15 17:08:36 UTC
I'm also experiencing this problem on Kubuntu's kandy package. Everything seems to work fine on my Fedora Core 2 installation.
Comment 3 Rolf Offermanns 2005-08-15 19:57:24 UTC
Same here (Kubuntu 5.04 package)
Comment 4 Rolf Offermanns 2005-08-15 20:09:23 UTC
See also: http://bugzilla.ubuntu.com/show_bug.cgi?id=13493
Comment 5 Rolf Offermanns 2005-08-16 01:21:10 UTC
I looked into this and now I am confused... :)
The bug is still present in the 3.5alpha1 release. The problem seems to be the following code in src/modem.cpp around line 194:
const char *fdev = QFile::encodeName( (*prefs).serialDevice() ).data();

fdev contains the garbled string. I inserted the following code:
printf("%s\n\n", fdev);
printf("%s\n\n", (*prefs).serialDevice().latin1());
printf("%s\n\n", fdev);

And this is the output (and kandy works with this):
 e/ircomm0

/dev/ircomm0

/dev/ircomm0

So... What am I missing here?
Comment 6 Rolf Offermanns 2005-08-16 11:16:35 UTC
Can someone please have a look at the following code (modem.cpp l.194). I think its wrong because QFile::encodeName() returns a QCString and QCString::data() returns a (const char *) Ptr. to the internal C-Array. But the QCString instance is deleted again immediately (isn't it?) thus invalidating the returned ptr. Right?

const char *fdev = QFile::encodeName( (*prefs).serialDevice() ).data();

I will create a patch and attach it here. Maybe it is of help for someone.
Comment 7 Andreas Kling 2006-07-20 14:43:48 UTC
SVN commit 564537 by kling:

Fixed the well-known problem with garbled device paths.
Patch has been lying around on bugzilla for over a year.

BUG: 39420
BUG: 45640
BUG: 47383
BUG: 96883
BUG: 104596
BUG: 101575



 M  +2 -1      modem.cpp  


--- branches/KDE/3.5/kdepim/kandy/src/modem.cpp #564536:564537
@@ -191,7 +191,8 @@
   if ( !lockDevice() )
     return false;
 
-  const char *fdev = QFile::encodeName( (*prefs).serialDevice() ).data();
+  QCString dev = QFile::encodeName( (*prefs).serialDevice() );
+  const char *fdev = dev.data();
   if ( ( fd = ::open( fdev, O_RDWR | O_NOCTTY | O_NONBLOCK ) ) == -1 ) {
     emit errorMessage( i18n( "Unable to open device '%1'. "
                              "Please check that you have sufficient permissions." )