4 * Copyright(C) 2008 Ixonos Plc
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Boston, MA 02111.
32 #include <glib/gstdio.h>
34 #include "../src/modem.h"
35 #include "../src/utils.h"
37 static void neo1973_close_serial (SerialInterface
*serial_if
, gint fd
)
42 static const gchar
*files
[] = {
43 "/sys/bus/platform/devices/neo1973-pm-gsm.0/download",
44 "/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on",
45 "/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on",
46 "/sys/bus/platform/devices/neo1973-pm-gsm.0/reset",
47 "/sys/bus/platform/devices/neo1973-pm-gsm.0/reset",
50 static const gchar
*file_contents
[] = {
58 static gint
neo1973_open_serial (SerialInterface
*serial_if
, const gchar
*device
)
61 while( files
[i
] && file_contents
[i
] ) {
62 if( g_file_test(files
[i
], G_FILE_TEST_IS_REGULAR
) ) {
63 FILE *f
= g_fopen(files
[i
],"wb");
65 gint len
= strlen(file_contents
[i
]);
66 gint written
= fwrite (file_contents
[i
], 1,len
, f
);
68 g_debug("Failed to write file: %s", files
[i
]);
71 g_usleep(G_USEC_PER_SEC
);
73 g_debug("Failed to open file: %s", files
[i
]);
78 g_usleep(G_USEC_PER_SEC
);
79 return gsmd_utils_default_serial_init(device
,
80 CS8
| CRTSCTS
| CREAD
| B115200
,
84 gboolean
serial_plugin_init ( SerialInterface
*serial_if
, ModemInterface
*modem
)
86 serial_if
->priv
= modem
;
87 serial_if
->open_serial
= &neo1973_open_serial
;
88 serial_if
->close_serial
= &neo1973_close_serial
;