Qtopia: GPRS

Ole Kliemann ole-om-community-2008 at mail.plastictree.net
Tue Jul 29 16:57:25 CEST 2008


On Tue, Jul 29, 2008 at 12:24:50PM +1000, Lorn Potter wrote:
> Ole Kliemann wrote:
> > On Sun, Jul 27, 2008 at 12:13:05PM +0000, Ole Kliemann wrote:
> >> I'm trying to send an MMS with Qtopia. I set up GPRS and WAP through the
> >> GUI, but it did not work; the network interface failed to start when
> >> sending. A look into the log shows this:
> >>
> >> Jul 27 09:57:37 om-gta02 user.notice Qtopia: Network :  Creating network session for "qtmail" on "/home/root/Applications/Network/config/dialupGPRS0.conf" 
> >> Jul 27 09:57:37 om-gta02 user.notice Qtopia: Network :  starting pppd (non-demand) : "/usr/sbin/pppd nodetach debug call dialup1217032395 password simyo logfile /tmp/qtopia-0/qpe-pppd-log-dialup1217032395 connect /opt/Qtopia/bin/qtopia-pppd-internal active /home/root/Appl
> >> Jul 27 09:57:37 om-gta02 user.notice Qtopia: QServiceDeviceBase::run: could not find a pseudo-tty
> >> Jul 27 09:57:37 om-gta02 user.notice Qtopia: Network : QModemDataCall::dial - could not start pppd
> > 
> > Qtopia launches pppd without a device parameter and redirects the modem
> > device through a pseudo-tty to the stdin/out of the pppd process. Qtopia
> > assumes BSD-style /dev/pty*, but on my FR I only got /dev/pts.
> > 
> > So I patched it for /dev/pts. Not sure how correct I have done this.
> 
> There is similar code in 4.4, I just added it to 4.3
> Thanks

I missed something with this patch. The ttyname is used later and was
not returned by createPseudoTty. That explains the garbage in the first
arg when launching pppd.

Funny thing is, a connection worked, although the device was not passed
to pppd. But I really don't understand yet how this whole thing works.
-------------- next part --------------
--- src/libraries/qtopiacomm/serial/qserialiodevice.cpp_orig	2008-07-29 14:27:05.000000000 +0200
+++ src/libraries/qtopiacomm/serial/qserialiodevice.cpp	2008-07-29 14:29:21.000000000 +0200
@@ -249,27 +249,22 @@
 #ifdef USE_POSIX_SYSCALLS
 
 // We would like to use "openpty", but it isn't in libc on some systems.
-static bool createPseudoTty(int& masterFd, int& slaveFd, char *ttyname)
+static bool createPseudoTty(int& masterFd, int& slaveFd, char **ttyname)
 {
-    static char const firstChars[]  = "pqrstuvwxyzabcde";
-    static char const secondChars[] = "0123456789abcdef";
-    const char *first;
-    const char *second;
-    char ptyname[16];
-    for ( first = firstChars; *first != '\0'; ++first ) {
-        for ( second = secondChars; *second != '\0'; ++second ) {
-            sprintf( ptyname, "/dev/pty%c%c", *first, *second );
-            sprintf( ttyname, "/dev/tty%c%c", *first, *second );
-            if ( ( masterFd = ::open( ptyname, O_RDWR | O_NONBLOCK, 0 ) ) >= 0 ) {
-                if ( ( slaveFd = ::open( ttyname, O_RDWR | O_NOCTTY, 0 ) )
-                        >= 0 ) {
-                    return true;
-                }
-                ::close( masterFd );
-            }
-        }
+    masterFd=::open("/dev/ptmx", O_RDWR | O_NONBLOCK);
+    if (masterFd<0)
+        return false;
+    if (::grantpt(masterFd)<0)
+        return false;
+    if (::unlockpt(masterFd)<0)
+        return false;
+    *ttyname=::ptsname(masterFd);
+    slaveFd=::open(*ttyname, O_RDWR | O_NOCTTY);
+    if (slaveFd<0) {
+        ::close(masterFd);
+        return false;
     }
-    return false;
+    return true;
 }
 
 #endif // USE_POSIX_SYSCALLS
@@ -304,8 +299,8 @@
     // Create a pseudo-tty to manage communication with the process.
     int masterFd = -1;
     int slaveFd = -1;
-    char slaveName[BUFSIZ];
-    if ( !createPseudoTty( masterFd, slaveFd, slaveName ) ) {
+    char *slaveName;
+    if ( !createPseudoTty( masterFd, slaveFd, &slaveName ) ) {
         qWarning( "QServiceDeviceBase::run: could not find a pseudo-tty" );
         return 0;
     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.openmoko.org/pipermail/community/attachments/20080729/0572465f/attachment.pgp 


More information about the community mailing list