GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > GSM Programming & Reverse Engineering

GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets.

Reply
 
LinkBack Thread Tools Display Modes
Old 07-26-2002, 21:20   #1 (permalink)
vz
Freak Poster
 
Join Date: Apr 2001
Location: Russia
Age: 36
Posts: 157
Member: 4372
Status: Offline
Thanks Meter: 1
Communication routine

Hello!
Who can share with me working routine for COM PORT that is using WIN32API?

Thanks!
  Reply With Quote
Old 08-28-2002, 21:09   #2 (permalink)
Product Manager
 
.:hack3r2k:.'s Avatar
 
Join Date: Aug 2002
Location: FuriouSTeaM
Age: 30
Posts: 38,789
Member: 15022
Status: Offline
Sonork: 100.53452
Thanks Meter: 40,214
Donate money to this user
This function opens a RS232 connection to a specified com port
;---------------------------------------------------------------------------------

HANDLE ConnectRS232(LPSTR PortName)
{
DCB dcb;
HANDLE hCommPort;
DWORD MAX_READ_BUFFER, MAX_WRITE_BUFFER, dwErr;
INT baud_rate[] ={110, 150, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 128000, 256000};


MAX_READ_BUFFER = MAX_WRITE_BUFFER = 4096;

hCommPort = CreateFile (PortName, GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);


dwErr = GetLastError();

if (dwErr == ERROR_ACCESS_DENIED)
{
MessageBox(hWnd,
"The selected port is curently in use !", "Error", MB_ICONERROR );
return INVALID_HANDLE_VALUE;
exit(1);
}
else
{

SetupComm (hCommPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER);
PurgeComm (hCommPort, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR);
SetCommMask(hCommPort, EV_BREAK | EV_RXFLAG);

comm.ReadIntervalTimeout = DWORD(-1);
comm.ReadTotalTimeoutMultiplier = 0;
comm.ReadTotalTimeoutConstant = 3000; //1000
comm.WriteTotalTimeoutMultiplier = 0;
comm.WriteTotalTimeoutConstant = 3000; //1000

SetCommTimeouts(hCommPort, &comm);

dcb.DCBlength = sizeof(DCB);
GetCommState( hCommPort, &dcb);



dcb.BaudRate = baud_rate[SendMessage(handle[12], CB_GETCURSEL, NULL, NULL)];
dcb.fBinary = TRUE;
dcb.fParity = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fOutxCtsFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_ENABLE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.fRtsControl = RTS_CONTROL_ENABLE;
dcb.ByteSize = 8;
dcb.Parity = 0;
dcb.StopBits = 0;
dcb.XoffLim = 0;
dcb.XonLim = 0;
if (SetCommState( hCommPort, &dcb) == FALSE)
{
MessageBox(hWnd, "Cannot set port params !", "Error", MB_ICONERROR);
return INVALID_HANDLE_VALUE;
exit(1);

}
EscapeCommFunction (hCommPort, SETDTR);
return hCommPort;
}
}

This function enumerates the com ports and sends the name to a combobox
;----------------------------------------------------------------------------------
void EnumSerialPorts(HWND ComboBox)
{
HANDLE hCommPort;
DWORD ErrorID;
CHAR PortName[260];
INT i;

for (i=1;i<=5;i++){

wsprintf(PortName, "COM%d", i);
hCommPort = CreateFile (PortName, GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, // | FILE_FLAG_OVERLAPPED,
NULL);
ErrorID = GetLastError();

if ((ErrorID == ERROR_ACCESS_DENIED) || (ErrorID == ERROR_SUCCESS)){
SendMessage(ComboBox, CB_ADDSTRING, NULL, (LPARAM)PortName);
CloseHandle(hCommPort);
}
}
SendMessage(ComboBox, CB_SETCURSEL, 0, NULL);
}

Well i hope that this will give u enough help (anyway u'll have to change the a little to adapt the m to you prog as the ones aboves are pasted from one of my programs)

About reading/writing routine i can give u a fixed routine as it depends from phone to phone. If u plan to use them use VC++ 7.0 as i used some values included only in 7.0 version (this ver is included in Visual Studio .NET)

P.S: Don't forget about the credit ...

best regards,
.:hack3r2k:.

Last edited by .:hack3r2k:.; 08-28-2002 at 21:14.
  Reply With Quote
Old 09-06-2002, 14:59   #3 (permalink)
vz
Freak Poster
 
Join Date: Apr 2001
Location: Russia
Age: 36
Posts: 157
Member: 4372
Status: Offline
Thanks Meter: 1
Thanks! it works for opening com ports.
But now I have the next problem.
Why when I'm trying to write something by the next way:

(for example):
char e[]="abc";
WriteFile(hComm, &e, 3, &writtenbytes, NULL);

on output I have "61 62 63 00" ?
As i know, I'm trying to write only 3 bytes, but ComSpy tell that
there was 4.
I don't know how to solve that problem and I'm asking for help!!
Help!
  Reply With Quote
Old 09-06-2002, 20:40   #4 (permalink)
Crazy Poster
 
Join Date: Jun 2002
Location: Spain
Posts: 52
Member: 12706
Status: Offline
Thanks Meter: 1
The last digits (00) appears when PC close the COM port.

Best Regards!!!
  Reply With Quote
Old 09-07-2002, 00:30   #5 (permalink)
Product Manager
 
.:hack3r2k:.'s Avatar
 
Join Date: Aug 2002
Location: FuriouSTeaM
Age: 30
Posts: 38,789
Member: 15022
Status: Offline
Sonork: 100.53452
Thanks Meter: 40,214
Donate money to this user
Talking Hey !

It writes xx xx xx 00 to port cause the string u are trying to write it's a null terminated string. After the bytes of the string u have 00. So the prog is right when it says that u are writing 2 port 4 bytes.


best regards,
.:hack3r2k:.
  Reply With Quote
Old 09-07-2002, 08:36   #6 (permalink)
vz
Freak Poster
 
Join Date: Apr 2001
Location: Russia
Age: 36
Posts: 157
Member: 4372
Status: Offline
Thanks Meter: 1
.:hack3r2k: You are not right. I gave many various number in the parameter of WriteFile's counter of written bytes.

gsmnow: Yes, it's true. But by the way my Siemens don't want to response to at commands. And I don't understand why.
On the command "at+cgmi" ended 0D, Siemens must to say SIEMENSOK and after some delay i can give next commands, but it's not work.

Who can explain the mechanism???
  Reply With Quote
Old 09-12-2002, 10:03   #7 (permalink)
No Life Poster
 
Join Date: Apr 2000
Location: Bulgaria
Posts: 729
Member: 1233
Status: Offline
Thanks Meter: 2
Can you give me compiled .exe for sending bytes/files via COM port,regardless of the device, attached on comport?
  Reply With Quote
Old 09-12-2002, 11:27   #8 (permalink)
vz
Freak Poster
 
Join Date: Apr 2001
Location: Russia
Age: 36
Posts: 157
Member: 4372
Status: Offline
Thanks Meter: 1
Try to use any terminal program.
Something like old and good Teleport Pro or something else.
There's many option that you can to configure and also you
can use the simpliest script language.
  Reply With Quote
Old 09-12-2002, 13:38   #9 (permalink)
No Life Poster
 
Join Date: Apr 2000
Location: Bulgaria
Posts: 729
Member: 1233
Status: Offline
Thanks Meter: 2
Quote:
Originally posted by vz
Try to use any terminal program.
Something like old and good Teleport Pro or something else.
There's many option that you can to configure and also you
can use the simpliest script language.
10x for replay.Can you guve me a link? Or if you can, send me at pavlinb@mail.bg
  Reply With Quote
Old 03-27-2003, 01:19   #10 (permalink)
Freak Poster
 
Join Date: Mar 2002
Location: madrid
Age: 43
Posts: 198
Member: 10148
Status: Offline
Thanks Meter: 1
Thumbs up parallel comunication

any example for visual basic how to comunicate with that?


thanks
  Reply With Quote
Old 03-27-2003, 09:07   #11 (permalink)
Insane Poster
 
Join Date: Feb 2003
Location: Poland
Age: 40
Posts: 76
Member: 22528
Status: Offline
Thanks Meter: 0
Quote:
Originally posted by Nutzo
Check baudrate (9600), databits (8), parity (N), stopbits (1),
RTS (disable) and DTR (disable).
BR,
If you use Siemens c25,c35,m35,s35 boudrate must be 19200 to can receive answer to AT commands.
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
thread Thread Starter Forum Replies Last Post
Anybody found the routine to read SMS in siemens flash? kxn x1x to x45/x50 0 07-30-2003 16:45
Anybody found the routine to read SMS in siemens flash? kxn GSM Programming & Reverse Engineering 0 07-30-2003 15:33
routines library's api's etc.. Paradox69 GSM Programming & Reverse Engineering 4 06-22-2003 21:13
PIC routines for serial communications majid GSM Programming & Reverse Engineering 9 06-22-2002 02:43
COM or Mbus Routine greenapple Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) 1 02-15-2002 02:44

 



All times are GMT +1. The time now is 22:35.



Powered by Searchlight © 2014 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2014 -
Page generated in 0.38981 seconds with 8 queries

SEO by vBSEO