does anyone know how i could send ascii to terminate my moderm?
i want to hard code <ctrl-Z> and i have found the ASCII of Ctrl-z, but how could i write this ASCII to the modem socket?
does anyone know how i could send ascii to terminate my moderm?
i want to hard code <ctrl-Z> and i have found the ASCII of Ctrl-z, but how could i write this ASCII to the modem socket?
Are you using socket to communicate with the modem? How?
In most cases - you open a com port for this purpose...
You can then write to the port as if it is file
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
fd= open(MODEM_DEV, PARAMS);
i am connecting to gsm modem
so basically i write to fd, but how i could send ascii number as ascii number and not string?
any command or function that i need to use?
string is just a sequence of ACSII numbers...
So just make a sequence of one character and write it
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
i am actually writing AT commands to gsm, like the following
write (fd, "AT+CMGS =\"+60125649001\"\r\nhello\n" ,40);
and i need <ctrl-z> to send out the message. however i need to hardcode this <ctrl-z>, if i wrote the ascii 01A, the program will treat 01A as part of the message, so how should i send this 01A to terminate the modem?
I dunno... try something likeCode:/* This assumes buffer is large enough to accommodate the following */ strcpy(buffer,"AT+CMGS =\"+60125649001\"\r\nhello\n"); buffer[strlen(buffer) + 1] = '\0'; buffer[strlen(buffer)] = (char)0x1A; write(fd, buffer, strlen(buffer) + 1);
Sent from my iPad®
Read the manual which comes with your modem perhaps?
Or maybe since you're using linux (I guess), then see if there is an ioctl() command to cause and end of file to be sent to the modem.
Or search the web for "AT commands".
From memory, there's something about sending "+++" to cause the modem to revert from data mode back into command mode.
Are you sure you don't mean
"ATZ"
As a command, rather than <ctrl-z> as a character?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
thanks thanks... i've got it to work!!!
i need a <ctrl-z> to send the message out
i have get the modem to sms out, but some coding that i not really understand why after i off the modem n reset it, the 1st command that i sent through will not be responsed?
strcpy(buffer, "AT+CMGS =\"25649001\"\r\nhello\n");
buffer[strlen(buffer)+1] = '\0';
buffer[strlen(buffer)] =(char)0x1A;
unless i add read () before the above code. anyone know why?
write (fd, buffer, strlen(buffer)+1);
Make sure the whole buffer was sent successfully.
Sent from my iPad®
bzero (buffer, sizeof(buffer));
read(fd, buffer, sizeof(buffer));
strcpy(buffer, "AT+CMGS =\"+60125649001\"\r\nhello\n");
buffer[strlen(buffer)+1] = '\0';
buffer[strlen(buffer)] =(char)0x1A;
write (fd, buffer, strlen(buffer)+1);
wait();
this is how the code looks like. the whole buffer was sent. But the problem comes each time i reset the modem. the function read above supposingly does nothing, but without read() while i reset the modem it seems couldnt get reply (perhaps it didnt send out the message for the 1st time).
Are you reopening your connection to your modem again? You probably have to. You are in effect, when you tell your modem to reset, shutting it off and turning it back on. You should have to open again.
Quzah.
Hope is the first step on the road to disappointment.
--->strcpy(buffer, "AT+CMGS =\"+60125649001\"\r\nhello\n");
buffer[strlen(buffer)+1] = '\0';
buffer[strlen(buffer)] =(char)0x1A;
strcpy(buffer, "AT+CMGS =\"+60125649001\"\r\nhello\n\x1A");
it works properly now. i guess i need to set the serial port each time i reset the modem or restart the pc.
thanks everyone