1 /* Test for reading memory on AT/Samsung driver */
7 #include "../libgammu/protocol/protocol.h" /* Needed for GSM_Protocol_Message */
8 #include "../libgammu/gsmstate.h" /* Needed for state machine internals */
9 #include "../libgammu/gsmphones.h" /* Phone data */
11 #include "../helper/memory-display.h"
15 #define BUFFER_SIZE 16384
17 extern GSM_Error
SAMSUNG_ReplyGetMemory(GSM_Protocol_Message
*msg
, GSM_StateMachine
* s
);
19 int main(int argc
, char **argv
)
21 GSM_Debug_Info
*debug_info
;
22 GSM_Phone_ATGENData
*Priv
;
24 unsigned char buffer
[BUFFER_SIZE
];
28 GSM_Protocol_Message msg
;
30 GSM_MemoryEntry Entry
;
32 /* Check parameters */
34 printf("Not enough parameters!\nUsage: samsung-get-memory comm.dump\n");
39 f
= fopen(argv
[1], "r");
41 printf("Could not open %s\n", argv
[1]);
46 len
= fread(buffer
, 1, sizeof(buffer
) - 1, f
);
48 printf("Could not read whole file %s\n", argv
[1]);
52 /* Zero terminate data */
58 /* Configure state machine */
59 debug_info
= GSM_GetGlobalDebug();
60 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
61 GSM_SetDebugLevel("textall", debug_info
);
63 /* Allocates state machine */
64 s
= GSM_AllocStateMachine();
65 test_result(s
!= NULL
);
66 debug_info
= GSM_GetDebug(s
);
67 GSM_SetDebugGlobal(TRUE
, debug_info
);
69 /* Initialize AT engine */
70 Data
= &s
->Phone
.Data
;
71 Data
->ModelInfo
= GetModelData(NULL
, NULL
, "unknown", NULL
);
72 Priv
= &s
->Phone
.Data
.Priv
.ATGEN
;
73 Priv
->ReplyState
= AT_Reply_OK
;
74 Priv
->SMSMode
= SMS_AT_PDU
;
75 Priv
->Charset
= AT_CHARSET_UCS2
;
76 s
->Phone
.Data
.Memory
= &Entry
;
82 SplitLines(msg
.Buffer
, msg
.Length
, &Priv
->Lines
, "\x0D\x0A", 2, "\"", 1, TRUE
);
85 error
= SAMSUNG_ReplyGetMemory(&msg
, s
);
86 gammu_test_result(error
, "SAMSUNG_ReplyGetMemory");
88 /* This is normally done by ATGEN_Terminate */
89 FreeLines(&Priv
->Lines
);
90 GetLineString(NULL
, NULL
, 0);
93 error
= PrintMemoryEntry(&Entry
, s
);
94 gammu_test_result(error
, "PrintMemoryEntry");
96 /* Free state machine */
97 GSM_FreeStateMachine(s
);
102 /* Editor configuration
103 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: