Fixed typo in error message.
[gsmd2.git] / serial / neo1973_serial.c
blobbcb1d40f2db1e261be25b8d0cf1d76e732c6262a
1 /*
2 * neo1973_serial.c
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)
9 * any later version.
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.
22 * Written by
23 * Heikki Paajanen
26 #include <termios.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 #include <string.h>
31 #include <glib.h>
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)
39 return;
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",
48 NULL
50 static const gchar *file_contents[] = {
51 "1",
52 "0",
53 "1",
54 "0",
55 "1",
56 NULL
58 static gint neo1973_open_serial (SerialInterface *serial_if, const gchar *device)
60 gint i = 0;
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");
64 if( f ) {
65 gint len = strlen(file_contents[i]);
66 gint written = fwrite (file_contents[i], 1,len , f);
67 if( written < len ) {
68 g_debug("Failed to write file: %s", files[i]);
70 fclose(f);
71 g_usleep(G_USEC_PER_SEC);
72 } else {
73 g_debug("Failed to open file: %s", files[i]);
76 i++;
78 g_usleep(G_USEC_PER_SEC);
79 return gsmd_utils_default_serial_init(device,
80 CS8 | CRTSCTS | CREAD | B115200,
81 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;
89 return TRUE;