SMS Server Tools 3
This site is hosted by Kekekasvi.com
 Menu
Basic information:
Additional information:
Support:
Get SMS Server Tools 3:
Additional Options

 Sponsored links

 Search
Custom Search

 Visitor locations
 
 SMS Server Tools 3 Community
Welcome, Guest. Please login or register. Fri Mar 29, 2024 10:58
SMSTools3 Community » Help and support Bottom

[solved] Huawei E220 and "Modem is not clear to send"

  This topic is locked

Page:  1

Author Post
Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Operating system name and version: RHEL 5.5
Version of smsd: 3.1.8
Smsd installed from: sources (build with spec-file from smstools-3.1.5-4.fc13.src.rpm)
Name and model of a modem / phone: Huawei E220
Interface: USB

Hi.

I have found that if to plug in the modem in the working computer and to start smsd, all works well, but if send computer to reboot, without unplug the modem, after reboot in the smsd logs there is a message:

Quote
2010-05-24 16:52:03,3, GSM1: Modem is not clear to send

And smsd does not work.
However, if before start smsd to run minicom, it (minicom) communicate to the modem and if to quit from minicom (Ctrl+A, X), after that smsd normally communicates with the modem. Also, helps ' rtscts = no '.

I have tried to find solution in Google and search at this forum, but have found nothing.

My config:



I have not found how to attach files to message, if it is necessary, I can send strace outputs for working and not working smsd and for minicom. For smsd the main (excuse me, if I was mistaken, I not the programmer) difference which I have found:

Working smsd:
Quote
open("/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NONBLOCK) = 5
[...]
ioctl(5, TIOCMGET, [TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_CAR|TIOCM_DSR]) = 0

Not working:
Quote
open("/dev/ttyUSB0", O_RDWR|O_NOCTTY|O_NONBLOCK) = 5
[...]
ioctl(5, TIOCMGET, [TIOCM_DTR|TIOCM_RTS]) = 0
nanosleep({0, 100000000}, NULL) = 0
(ioctl and nanosleep repeats some times)
[...]
write(3, "2010-05-24 14:58:04,3, GSM1: Modem is not clear to send\n", 56) = 56

Can you help me, it is possible to solve this problem without using ' rtscts = no'?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thank's for the brief report.

I think that I have to examine this problem more deeply, but with a quick view there was an interesting comment in the source code of Minicom: "/* Set RTS line. Sometimes dropped. Linux specific? */". The handling of serial port looks very much the same as with smstools, but this comment may mean that even when there is RTS bit set, the line is not active and workaround is needed.

I hope that you can try the following addition to the code: In the file modeminit.c, locate the following and insert lines which are shown bold and red:


   default:
     writelogfile(LOG_ERR, 0, "Baudrate %d not supported, using 19200", baudrate);
     baudrate = B19200;
     DEVICE.baudrate = 19200;
 }
 cfsetispeed(&newtio, baudrate);
 cfsetospeed(&newtio, baudrate);
 tcsetattr(modem_handle, TCSANOW, &newtio);

 {
   int mcs = 0;

   ioctl(modem_handle, TIOCMGET, &mcs);
   mcs |= TIOCM_RTS;
   ioctl(modem_handle, TIOCMSET, &mcs);
 }


}

int initmodem(char *new_smsc, int receiving)

Hopefully this helps, but whatever happens, let me know.

Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
I made changes in modeminit.c, but nothing has changed

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Too bad... :(

After rebooting with a modem connected, do you have strace output for minicom available. If you have, it could be helpful.

Instructions in the private block:

Hidden private text.



Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
I have sent output of 'strace -o strace.log -ff -s 1024 -v smsd -t'

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thanks.

When this issue with a port is active, it could be interesting to see how minicom handles it. I was unable to reproduce that with my machine. Do you have that (or get a new one) output for minicom?

Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
I have sent archive

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Could it be possible that your minicom is not using CTS/RTS-control?

Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
I do not know, I use standard minicom from the CentOS. I start it as 'minicom usb0', but simple 'minicom' works too.

Contents minirc.usb0:

pr port/dev/ttyUSB0
pu baudrate 9600

Contents minirc.dfl:

pr port/dev/ttyUSB0
pu baudrate 9600
pu bits 8
pu parity N
pu stopbits 1

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Strange, but it seems that the CTS flag does not work properly. It is not set, but minicom still can send the init string to the modem. Later the flag checked, and it's still not set, but the communication works. After a while, there is one timeout and then the flag is set...

Anyways, here is more changes to the modeminit.c:


int write_to_modem(char *command, int timeout, int log_command, int print_error)
{
 int status=0;
 int timeoutcounter=0;
 int x=0;
 struct termios tio;

 tcgetattr(modem_handle, &tio);

 tio.c_cflag = 0;

 if (command && command[0])
 {
   if (!DEVICE_IS_SOCKET && tio.c_cflag & CRTSCTS)
   {
     ioctl(modem_handle, TIOCMGET, &status);
     while (!(status & TIOCM_CTS))
     {
       usleep(100000);
       timeoutcounter++;
       ioctl(modem_handle, TIOCMGET, &status);
       if (timeoutcounter>timeout)
       {
         if (print_error)
           printf("\nModem is not clear to send.\n");
         else
         {
           writelogfile0(LOG_ERR, 1, tb_sprintf("Modem is not clear to send"));
           alarm_handler0(LOG_ERR, tb);
         }
         return 0;
       }
     }
   }
   if (log_command)
     writelogfile(LOG_DEBUG, 0, "-> %s",command);

   if (1)
   {
     size_t r = 0, bs, n;
     ssize_t got;
     fd_set writefds;

     n = strlen(command);
     while (n > 0)
     {
       bs = (DEVICE.send_delay < 1) ? n : 1;
       got = write(modem_handle, command + r, bs);
       if (got < 0)
       {
         if (errno == EINTR)
           continue;

         if (errno != EAGAIN)
         {
           writelogfile0(LOG_ERR, 1, tb_sprintf("Serial write: write error %d: %s",
                         errno, strerror(errno)));
           alarm_handler0(LOG_ERR, tb);
           return 0;
         }

         writelogfile0(LOG_DEBUG, 1, tb_sprintf("Serial write: transmitter busy, waiting"));
         alarm_handler0(LOG_DEBUG, tb);
         FD_ZERO(&writefds);
         FD_SET(modem_handle, &writefds);
         select(modem_handle + 1, NULL, &writefds, NULL, NULL);
         writelogfile0(LOG_DEBUG, 1, tb_sprintf("Serial write: transmitter ready"));
         continue;
       }

       n -= got;
       r += got;
       if (DEVICE.send_delay > 0)
         usleep(DEVICE.send_delay *1000);
     }
   }
   else


   // 3.1.5:
   if (DEVICE.send_delay < 1)



« Last edit by keke on Wed May 26, 2010 08:22, 168 months ago. »
Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
It works (even without the first patch), but in log periodically there are records:

Quote
2010-05-26 11:58:21,3, GSM1: Serial write: transmitter busy, waiting
2010-05-26 11:58:21,3, GSM1: Serial write: transmitter ready


Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Great!

Those messages prove that the handshaking works and also that the handshaking is required on your system. You could change the severity of those messages from LOG_ERR to LOG_DEBUG. I have modified my previous posting from that point.

Even when the original way to handle handshaking has been in use about ten years, I will include this new style in the next version.

Thank you for all the reporting and testing.

Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
I need only last (big) patch, or a patch from #2 message (small) also is necessary?


If I have correctly understood, in the following version (3.1.9?) there will be all necessary changes and there will be no necessity of patches from this topic?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
lithium wrote
I need only last (big) patch, or a patch from #2 message (small) also is necessary?

Only the last patch is required.

lithium wrote
If I have correctly understood, in the following version (3.1.9?) there will be all necessary changes and there will be no necessity of patches from this topic?

Yes, all changes will be included in the 3.1.9. I do not yet publish it, because this problem has been very uncommon.

Member
Registered:
Apr 2010
Location: Krasnodar, Russian Federation
Topic owner
Thank you very much for the help! :)

  This topic is locked

Page:  1

SMSTools3 Community » Help and support Top

 
Time in this board is UTC.  

Privacy Policy   SMS Server Tools 3 Copyright © Keijo Kasvi.