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. Thu Apr 25, 2024 19:02
SMSTools3 Community » Help and support Bottom

[changed in 3.1.12] how to write ctrl+z code in terminal and cmd file

  This topic is locked

Page:  1

Author Post
Member
Registered:
Mar 2010
Location: depok, Indonesia
Operating system name and version: linux
Version of smsd: 3.1.7beta
Smsd installed from: sources
Name and model of a modem / phone: wavecom Q2403A
Interface: USB

Hi Keke.. nice to meet you again.. so long time.. :)
I don't know until now i can't receive long sms on m600i.
maybe next time, W open again the topic :)

Now I have problem in write ctrl+z in terminal(smsd -C GSM1) and regular_run_cmdfile.
That run some code for running STK.
When I press the ctrl+z in terminal, the program terminate to prompt, because the entri need 14 digit but i only need enter 11 digit so Ctrl+z is needed. This in terminal :


This in file:


Please help.. maybe i'm not correct in methode, please advice.
Thanks, :)
-alfin-


« Last edit by alfinsi on Thu Jul 15, 2010 10:15, 167 months ago. »
Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
alfinsi wrote
Now I have problem in write ctrl+z in terminal(smsd -C GSM1) and regular_run_cmdfile.
That run some code for running STK.
When I press the ctrl+z in terminal, the program terminate to prompt, because the entri need 14 digit but i only need enter 11 digit so Ctrl+z is needed.

When starting communication mode, the smsd says:

Communicating with GSM1. ( Press Ctrl-C to abort. )
( If you need to send Ctrl-Z, change the suspend character first, like stty susp \^N )
Default device is /dev/ttyUSB1
Press Enter to start or type an another device name.


So, before starting communication mode, change the suspend character.

alfinsi wrote
echo $TEXT"0x1A" >> $TMPFILE

This should work:

echo $TEXT$'\x1A' >> $TMPFILE

Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
I have change the code like this:

echo $TEXT$'\x1A' >> $TMPFILE

but still error :( . I have copied the log bellow
Oh ya please give an example write suspend character, because I was read in configuration doc. The sintak is suspend=filename (put in global)



Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Your script is probably using #!/bin/sh, which may be a symbolic link to the /bin/dash, but my command was in syntax of bash shell. Because of this, your script is not writing Ctrl-Z character correctly to the file, as you can see from the log.

Hopefully this script will help you. Run it and check what is the result:

#!/bin/bash

TEXT="ABC"
FILE=`mktemp /tmp/test_XXXXXX`
echo $TEXT$'\x1A' > $FILE
hexdump -C < $FILE
rm $FILE
 
'bash' Syntax Highlight powered by GeSHi


In my case, the result is:



There is a character 1a correctly.


Suspend character has nothing to do with a global setting suspend = filename. See man stty for details. For example, stty -a will tell you that "susp = ^Z", and because of this, you cannot send Ctrl-Z when using communication mode. You have to change the suspend character, for example as the instruction said: stty susp \^N. After this command, the suspend character is Ctrl-N and you can start communication mode and you are able to send Ctrl-Z to the modem.

Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
Ok, Success press ctrl+z in terminal with type stty susp \^N first.
But in cmd file is still Error.

I have added line #!/bin/bash, the script is writing Ctrl-Z character correctly to the file, but the process still same error.
This is like the Ctrl-Z doesn't work, thats like when i haven't run stty susp \^N in terminal mode.
May be this case need to change the suspend character first too.. before run the script. But how to write ?

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
You need to change the suspend character only when using the communication mode.

There is a problem in the code of smsd. In the function run_rr(), there is a call cut_ctrl(st) which is used to remove line breaks. However, this call removes also Ctrl-Z because it's a control character. I have change this, probably within a next few days, and include the change in the 3.1.12.

Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
Ok, I'll check that function too.. for my addon knowledge.. :)
But for the best result, I'm waiting 3.1.12 release.
I'll try and give the report soon.. I'm glad tobe one of contributors for this project.
Thank you so much keke :)

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
As you have compiled smsd from sources, you could apply the following changes. They fit to 3.1.7beta too, if necessary. Indentation does not matter.

The first change will fix the Ctrl-Z issue in smsd.c:

 // cmd_to_modem opens a modem if necessary.
 if (DEVICE.dev_rr_cmdfile[0])
 {
   if ((fp = fopen(DEVICE.dev_rr_cmdfile, "r")))
   {
     while (fgets(st, sizeof(st), fp))
     {
       // 3.1.12: remove only linebreaks:
       //cutspaces(st);
       //cut_ctrl(st);
       while (*st && strchr("\r\n", st[strlen(st) -1]))
         st[strlen(st) -1] = 0;

       if (*st && *st != '#')


The second change is required, because the command at+stgr=3,1; gives > as an answer, but the code is expecting OK or ERROR. With this change you can define that command as:
(>)at+stgr=3,1;

Smsd is then expecting >, and there will be no timeout and no error.

               // 3.1.5: Special case: AT+CUSD, wait USSD message:
               //put_command(*modem, device, cmd, answer, sizeof(answer), 1, EXPECT_OK_ERROR);
               if (!strncasecmp(command, "AT+CUSD", 7) && strlen(command) > 9)
               {
                       is_ussd++;
                       put_command(cmd, answer, sizeof(answer), 3, "(\\+CUSD:)|(ERROR)");
               }
               else
               // 3.1.12:
               if (*cmd == '(' && strchr(cmd, ')'))
               {
                       char *expect;

                       if ((expect = strdup(cmd)))
                       {
                               *(strchr(expect, ')') + 1) = 0;
                               put_command(strchr(cmd, ')') + 1, answer, sizeof(answer), 1, expect);
                               free(expect);
                       }
               }
               else
               // -------

                       put_command(cmd, answer, sizeof(answer), 1, EXPECT_OK_ERROR);

               if (*answer)



« Last edit by keke on Fri Jul 23, 2010 09:15, 167 months ago. »
Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
I have been changed both code and compiled, the Ctrl-Z still doesn't work.
i've modified my script to be like this:


the result:


Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
Thanks for reporting this. I have changed the first patch, there was cutspaces() used and it removed Ctrl-Z. Comment out that call and recompile and try again.

Have you noticed that in your script the echo 333333 >> $TMPFILE probably should have $'\x1A' too?

Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
Ok.. that's work properly and no error found inculde The echo 333333 >> $TMPFILE

The echo 333333 >> $TMPFILE is just direct value that suitable with the digit length required, actually this isn't couse the error.
The error appers, becouse this script is run sequential, so when 1 step error the next line will be error too..

Thank you so much keke :)
nice work with you

Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
Keke.. there is a question;
After Ctrl-Z applied is there need a delay time ?
becouse i have to add two lines for manipulate the error for the success process, like this:
Quote
echo $TEXT$'\x1A' >> $TMPFILE
echo "at+stgi=6;" >> $TMPFILE
echo "at+stgr=6,1,1;" >> $TMPFILE

echo "at+stgi=6;" >> $TMPFILE
echo "at+stgr=6,1,1;" >> $TMPFILE
echo "at+stgi=6;" >> $TMPFILE
echo "at+stgr=6,1,1;" >> $TMPFILE
echo "at+stgi=3;" >> $TMPFILE
echo "(>)at+stgr=3,1;" >> $TMPFILE

the result:


from the log we can see, after ^Z the unswer is just OK not OK +STIN:6, So when next cmd AT+STGI=6 the unswer is <- +CME ERROR: 518 +STIN: 6, becouse STIN:6 is late.
So i push add 2 line again for manipulate.
Please advice, what should i do..

Member
Registered:
Mar 2010
Location: depok, Indonesia
Topic owner
ok sorry, the problem solved :)
i was modified the script like this
Quote
echo "at" > $TMPFILE
echo "at+stgi=0;" >> $TMPFILE
echo "at+stgr=0,1,1;" >> $TMPFILE
echo "at+stgi=3;" >> $TMPFILE
# echo "(>)at+stgr=3,1;" >> $TMPFILE
echo "(>)at+stgr=3,1,\"$TEXT\";" >> $TMPFILE
echo $'\x1A' >> $TMPFILE

# echo $TEXT$'\x1A' >> $TMPFILE
# echo "at+stgi=6;" >> $TMPFILE
# echo "at+stgr=6,1,1;" >> $TMPFILE
echo "at+stgi=6;" >> $TMPFILE
echo "at+stgr=6,1,1;" >> $TMPFILE
echo "at+stgi=6;" >> $TMPFILE

Thanks, i hope this useful for others :)

Administrator
Registered:
May 2009
Location: Jyväskylä, Finland
For your information, this change will be included in the 3.1.12, BUT the format is slightly different. To allow multiple words to be defined, square brackets are used. For example:

[(>)]AT+STGR=3,1;

or:

[(>)|(ERROR)]AT+STGR=3,1;

Be aware with this change when you move to the 3.1.12 (after it's released, it is not yet but I'm working with it now).

  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.