aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2011-10-03 17:53:23 +0200
committerSimon Busch <morphis@gravedo.de>2011-10-03 17:53:23 +0200
commit43f9048b5c141d95179f433aea8434d0da5db11f (patch)
tree7acd6ac5761639654414ccd903c149b58d97ce59 /tools
parentddefad23e5b5c47174bdf695f4ef9d92c184dd09 (diff)
downloadexternal_libsamsung-ipc-43f9048b5c141d95179f433aea8434d0da5db11f.zip
external_libsamsung-ipc-43f9048b5c141d95179f433aea8434d0da5db11f.tar.gz
external_libsamsung-ipc-43f9048b5c141d95179f433aea8434d0da5db11f.tar.bz2
Add modemctrl utility to test functionality of samsung-ipc
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am14
-rw-r--r--tools/modemctrl.c89
2 files changed, 103 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
new file mode 100644
index 0000000..2cfa871
--- /dev/null
+++ b/tools/Makefile.am
@@ -0,0 +1,14 @@
+NULL =
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+bin_PROGRAMS = modemctrl
+
+modemctrl_SOURCES = \
+ modemctrl.c \
+ $(NULL)
+
+modemctrl_LDADD = $(top_srcdir)/samsung-ipc/libsamsung-ipc.la
+modemctrl_LDFLAGS =
diff --git a/tools/modemctrl.c b/tools/modemctrl.c
new file mode 100644
index 0000000..ddfc530
--- /dev/null
+++ b/tools/modemctrl.c
@@ -0,0 +1,89 @@
+/**
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com>
+ *
+ * libsamsung-ipc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <radio.h>
+
+void handle_msg(struct ipc_response *response)
+{
+ if(response->command == IPC_PWR_PHONE_PWR_UP &&
+ response->type == IPC_TYPE_NOTI) {
+ printf(">> received PWR_PHONE_ONLINE, requesting IMEI\n");
+
+ /* h1 requires a short delay for nvram to be available */
+ usleep(25000);
+ ipc_msg_send(IPC_MISC_ME_SN, IPC_TYPE_GET, NULL, 0, 0x42);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ struct ipc_response response;
+ int error;
+
+ ipc_init(IPC_CLIENT_TYPE_CRESPO);
+
+ printf("ipc_open\n");
+ error = ipc_open();
+
+ if(error) {
+ fprintf(stderr, "ipc_open failed!\n");
+ return 1;
+ }
+
+ printf("ipc_power_on\n");
+ ipc_power_on();
+
+ printf("entering recv loop...\n");
+
+ while(1) {
+ error = ipc_recv(&response);
+
+ if(!error) {
+ printf("%s %s (%u/%u) type=%04x mseq=%02x aseq=%02x\n",
+ ipc_str(&response), ipc_response_type(&response),
+ (response.data_length + 7), response.data_length,
+ response.type, response.mseq, response.aseq);
+
+ hex_dump(response.data, response.data_length);
+ printf("\n");
+
+ handle_msg(&response);
+
+ if(response.data) {
+ free(response.data);
+ }
+ } else {
+ fprintf(stderr, "ipc_recv failed!\n");
+ return 1;
+ }
+ }
+
+ error = ipc_close();
+
+ if(error) {
+ fprintf(stderr, "ipc_close failed!\n");
+ return 1;
+ }
+
+ return 0;
+}