author | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 11:13:51 (UTC) |
commit | 50ab40e1e02ad7c65c17a78d08116a808b1257aa (patch) (unidiff) | |
tree | 0d1939e2297fa7bbd8e1f2030f154463854164c6 /gammu/emb/common/device | |
parent | cf8616f64f20e5448d4ff644f7cc15750cf3f85f (diff) | |
download | kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.zip kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.gz kdepimpi-50ab40e1e02ad7c65c17a78d08116a808b1257aa.tar.bz2 |
updated to latest gammu version
-rw-r--r-- | gammu/emb/common/device/bluetoth/bluez.c | 29 | ||||
-rw-r--r-- | gammu/emb/common/device/devfunc.c | 12 | ||||
-rw-r--r-- | gammu/emb/common/device/irda/irda.c | 8 | ||||
-rw-r--r-- | gammu/emb/common/device/irda/irda_unx.h | 2 | ||||
-rw-r--r-- | gammu/emb/common/device/serial/ser_djg.c | 10 | ||||
-rw-r--r-- | gammu/emb/common/device/serial/ser_unx.c | 38 | ||||
-rw-r--r-- | gammu/emb/common/device/serial/ser_w32.c | 6 |
7 files changed, 79 insertions, 26 deletions
diff --git a/gammu/emb/common/device/bluetoth/bluez.c b/gammu/emb/common/device/bluetoth/bluez.c index 8a4807e..e7e8adf 100644 --- a/gammu/emb/common/device/bluetoth/bluez.c +++ b/gammu/emb/common/device/bluetoth/bluez.c | |||
@@ -1,25 +1,34 @@ | |||
1 | /* Based on work by Marcel Holtmann and other authors of Bluez */ | 1 | /* Based on some work from Bluez (www.bluez.org) |
2 | * (C) 2000-2001 Qualcomm Incorporated | ||
3 | * (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> | ||
4 | * (C) 2002-2004 Marcel Holtmann <marcel@holtmann.org> | ||
5 | * GNU GPL version 2 | ||
6 | */ | ||
7 | /* based on some Marcel Holtmann work from Gnokii (www.gnokii.org) | ||
8 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
9 | * GNU GPL version 2 or later | ||
10 | */ | ||
2 | 11 | ||
3 | #include "../../gsmstate.h" | 12 | #include "../../gsmstate.h" |
4 | 13 | ||
5 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE | 14 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE |
6 | #ifdef GSM_ENABLE_BLUEZ | 15 | #ifdef GSM_ENABLE_BLUEZ |
7 | 16 | ||
8 | #include <stdlib.h> | 17 | #include <stdlib.h> |
9 | #include <stdio.h> | 18 | #include <stdio.h> |
10 | #include <fcntl.h> | 19 | #include <fcntl.h> |
11 | #include <errno.h> | 20 | #include <errno.h> |
12 | #include <string.h> | 21 | #include <string.h> |
13 | #include <sys/socket.h> | 22 | #include <sys/socket.h> |
14 | #include <sys/time.h> | 23 | #include <sys/time.h> |
15 | #include <unistd.h> | 24 | #include <unistd.h> |
16 | #include <bluetooth/bluetooth.h> | 25 | #include <bluetooth/bluetooth.h> |
17 | #include <bluetooth/rfcomm.h> | 26 | #include <bluetooth/rfcomm.h> |
18 | #include <bluetooth/sdp.h> | 27 | #include <bluetooth/sdp.h> |
19 | #include <bluetooth/sdp_lib.h> | 28 | #include <bluetooth/sdp_lib.h> |
20 | 29 | ||
21 | #include "../../gsmcomon.h" | 30 | #include "../../gsmcomon.h" |
22 | #include "../devfunc.h" | 31 | #include "../devfunc.h" |
23 | #include "bluetoth.h" | 32 | #include "bluetoth.h" |
24 | 33 | ||
25 | GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device) | 34 | GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device) |
@@ -60,148 +69,148 @@ GSM_Error bluetooth_connect(GSM_StateMachine *s, int port, char *device) | |||
60 | 69 | ||
61 | d->hPhone = fd; | 70 | d->hPhone = fd; |
62 | return ERR_NONE; | 71 | return ERR_NONE; |
63 | } | 72 | } |
64 | 73 | ||
65 | #ifdef BLUETOOTH_RF_SEARCHING | 74 | #ifdef BLUETOOTH_RF_SEARCHING |
66 | 75 | ||
67 | struct search_context { | 76 | struct search_context { |
68 | char *svc; | 77 | char *svc; |
69 | uuid_t group; | 78 | uuid_t group; |
70 | int tree; | 79 | int tree; |
71 | uint32_t handle; | 80 | uint32_t handle; |
72 | }; | 81 | }; |
73 | 82 | ||
74 | static void print_service_desc(void *value, void *user) | 83 | static void print_service_desc(void *value, void *user) |
75 | { | 84 | { |
76 | sdp_data_t *p = (sdp_data_t *)value; | 85 | sdp_data_t *p = (sdp_data_t *)value; |
77 | int i = 0, proto = 0, *channel = (int *)user; | 86 | int i = 0, proto = 0, *channel = (int *)user; |
78 | 87 | ||
79 | for (; p; p = p->next, i++) { | 88 | for (; p; p = p->next, i++) { |
80 | switch (p->dtd) { | 89 | switch (p->dtd) { |
81 | case SDP_UUID16: | 90 | case SDP_UUID16: |
82 | case SDP_UUID32: | 91 | case SDP_UUID32: |
83 | case SDP_UUID128: | 92 | case SDP_UUID128: |
84 | proto = 1;//sdp_uuid_to_proto(&p->val.uuid); | 93 | proto = sdp_uuid_to_proto(&p->val.uuid); |
85 | break; | 94 | break; |
86 | case SDP_UINT8: | 95 | case SDP_UINT8: |
87 | if (proto == RFCOMM_UUID) { | 96 | if (proto == RFCOMM_UUID) { |
88 | (*channel) = p->val.uint8; | 97 | (*channel) = p->val.uint8; |
89 | return; | 98 | return; |
90 | } | 99 | } |
91 | break; | 100 | break; |
92 | } | 101 | } |
93 | } | 102 | } |
94 | } | 103 | } |
95 | 104 | ||
96 | void print_access_protos(value, user) | 105 | void print_access_protos(value, user) |
97 | { | 106 | { |
98 | sdp_list_t *protDescSeq = (sdp_list_t *)value; | 107 | sdp_list_t *protDescSeq = (sdp_list_t *)value; |
99 | int *channel = (int *)user; | 108 | int *channel = (int *)user; |
100 | 109 | ||
101 | sdp_list_foreach(protDescSeq,print_service_desc,channel); | 110 | sdp_list_foreach(protDescSeq,print_service_desc,channel); |
102 | } | 111 | } |
103 | 112 | ||
104 | static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context) | 113 | static GSM_Error bluetooth_checkdevice(GSM_StateMachine *s, bdaddr_t *bdaddr, struct search_context *context) |
105 | { | 114 | { |
106 | sdp_session_t *sess; | 115 | sdp_session_t *sess; |
107 | sdp_list_t *attrid, *search, *seq, *next, *proto = 0; | ||
108 | uint32_t range = 0x0000ffff; | ||
109 | char str[20]; | ||
110 | sdp_record_t *rec; | 116 | sdp_record_t *rec; |
117 | sdp_list_t *attrid, *search, *seq, *next, *proto = 0; | ||
111 | sdp_data_t *d; | 118 | sdp_data_t *d; |
112 | bdaddr_t interface; | 119 | bdaddr_t interface; |
120 | uint32_t range = 0x0000ffff; | ||
113 | struct search_context subcontext; | 121 | struct search_context subcontext; |
122 | char str[20]; | ||
114 | int channel,channel2; | 123 | int channel,channel2; |
115 | 124 | ||
116 | bacpy(&interface,BDADDR_ANY); | 125 | bacpy(&interface,BDADDR_ANY); |
117 | 126 | ||
118 | ba2str(bdaddr, str); | 127 | ba2str(bdaddr, str); |
119 | smprintf(s,"%s\n", str); | 128 | smprintf(s,"%s\n", str); |
120 | 129 | ||
121 | sess = sdp_connect(&interface, bdaddr, SDP_RETRY_IF_BUSY); | 130 | sess = sdp_connect(&interface, bdaddr, SDP_RETRY_IF_BUSY); |
122 | if (!sess) { | 131 | if (!sess) { |
123 | dbgprintf("Failed to connect to SDP server on %s: %s\n", str, strerror(errno)); | 132 | dbgprintf("Failed to connect to SDP server on %s: %s\n", str, strerror(errno)); |
124 | return ERR_UNKNOWN; | 133 | return ERR_UNKNOWN; |
125 | } | 134 | } |
126 | 135 | ||
127 | attrid = sdp_list_append(0, &range); | 136 | attrid = sdp_list_append(0, &range); |
128 | search = sdp_list_append(0, &context->group); | 137 | search = sdp_list_append(0, &context->group); |
129 | if (sdp_service_search_attr_req(sess, search, SDP_ATTR_REQ_RANGE, attrid, &seq)) { | 138 | if (sdp_service_search_attr_req(sess, search, SDP_ATTR_REQ_RANGE, attrid, &seq)) { |
130 | dbgprintf("Service Search failed: %s\n", strerror(errno)); | 139 | dbgprintf("Service Search failed: %s\n", strerror(errno)); |
131 | sdp_close(sess); | 140 | sdp_close(sess); |
132 | return ERR_UNKNOWN; | 141 | return ERR_UNKNOWN; |
133 | } | 142 | } |
134 | sdp_list_free(attrid, 0); | 143 | sdp_list_free(attrid, 0); |
135 | sdp_list_free(search, 0); | 144 | sdp_list_free(search, 0); |
136 | 145 | ||
137 | channel2 = -1; | 146 | channel2 = -1; |
138 | for (; seq; seq = next) { | 147 | for (; seq; seq = next) { |
139 | rec = (sdp_record_t *) seq->data; | 148 | rec = (sdp_record_t *) seq->data; |
140 | 149 | ||
141 | if (channel2 == -1) { | 150 | if (channel2 == -1) { |
142 | if (!context->tree) { | 151 | if (!context->tree) { |
143 | d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY); | 152 | d = sdp_data_get(rec,SDP_ATTR_SVCNAME_PRIMARY); |
144 | 153 | ||
145 | if (false) { | 154 | if (sdp_get_access_protos(rec,&proto) == 0) { |
146 | channel = -1; | 155 | channel = -1; |
147 | sdp_list_foreach(proto,print_access_protos,&channel); | 156 | sdp_list_foreach(proto,print_access_protos,&channel); |
148 | //sdp_list_free(proto,(sdp_free_func_t)sdp_data_free); | 157 | sdp_list_free(proto,(sdp_free_func_t)sdp_data_free); |
149 | } | 158 | } |
150 | smprintf(s,"Channel %i",channel); | 159 | smprintf(s,"Channel %i",channel); |
151 | if (d) smprintf(s," - \"%s\"",d->val.str); | 160 | if (d) smprintf(s," - \"%s\"",d->val.str); |
152 | smprintf(s,"\n"); | 161 | smprintf(s,"\n"); |
153 | if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) { | 162 | if (channel2 == -1 && bluetooth_checkservicename(s, d->val.str) == ERR_NONE) { |
154 | channel2 = channel; | 163 | channel2 = channel; |
155 | } | 164 | } |
156 | } | 165 | } |
157 | if (sdp_get_group_id(rec,&subcontext.group) != -1) { | 166 | if (sdp_get_group_id(rec,&subcontext.group) != -1) { |
158 | memcpy(&subcontext, context, sizeof(struct search_context)); | 167 | memcpy(&subcontext, context, sizeof(struct search_context)); |
159 | if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext); | 168 | if (subcontext.group.value.uuid16 != context->group.value.uuid16) bluetooth_checkdevice(s,bdaddr,&subcontext); |
160 | } | 169 | } |
161 | } | 170 | } |
162 | 171 | ||
163 | next = seq->next; | 172 | next = seq->next; |
164 | free(seq); | 173 | free(seq); |
165 | //sdp_record_free(rec); | 174 | sdp_record_free(rec); |
166 | } | 175 | } |
167 | sdp_close(sess); | 176 | sdp_close(sess); |
168 | 177 | ||
169 | if (channel2 != -1) return bluetooth_connect(s, channel2, str); | 178 | if (channel2 != -1) return bluetooth_connect(s, channel2, str); |
170 | 179 | ||
171 | return ERR_UNKNOWN; | 180 | return ERR_NOTSUPPORTED; |
172 | } | 181 | } |
173 | 182 | ||
174 | GSM_Error bluetooth_findchannel(GSM_StateMachine *s) | 183 | GSM_Error bluetooth_findchannel(GSM_StateMachine *s) |
175 | { | 184 | { |
176 | inquiry_info ii[20]; | 185 | inquiry_info ii[20]; |
177 | uint8_t count = 0; | 186 | uint8_t count = 0; |
178 | int i; | 187 | int i; |
179 | struct search_context context; | 188 | struct search_context context; |
180 | GSM_Error error = ERR_NOTSUPPORTED; | 189 | GSM_Error error = ERR_NOTSUPPORTED; |
181 | 190 | ||
182 | memset(&context, '\0', sizeof(struct search_context)); | 191 | memset(&context, '\0', sizeof(struct search_context)); |
183 | //sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP); | 192 | sdp_uuid16_create(&(context.group),PUBLIC_BROWSE_GROUP); |
184 | 193 | ||
185 | if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) { | 194 | if (!strcmp(s->CurrentConfig->Device,"/dev/ttyS1")) { |
186 | dbgprintf("Searching for devices\n"); | 195 | dbgprintf("Searching for devices\n"); |
187 | if (sdp_general_inquiry(ii, 20, 8, &count) < 0) { | 196 | if (sdp_general_inquiry(ii, 20, 8, &count) < 0) { |
188 | return ERR_UNKNOWN; | 197 | return ERR_UNKNOWN; |
189 | } | 198 | } |
190 | } else { | 199 | } else { |
191 | count = 1; | 200 | count = 1; |
192 | str2ba(s->CurrentConfig->Device,&ii[0].bdaddr); | 201 | str2ba(s->CurrentConfig->Device,&ii[0].bdaddr); |
193 | } | 202 | } |
194 | for (i=0;i<count;i++) { | 203 | for (i=0;i<count;i++) { |
195 | error = bluetooth_checkdevice(s,&ii[i].bdaddr,&context); | 204 | error = bluetooth_checkdevice(s,&ii[i].bdaddr,&context); |
196 | if (error == ERR_NONE) return error; | 205 | if (error == ERR_NONE) return error; |
197 | } | 206 | } |
198 | return error; | 207 | return error; |
199 | } | 208 | } |
200 | 209 | ||
201 | #endif | 210 | #endif |
202 | #endif | 211 | #endif |
203 | #endif | 212 | #endif |
204 | 213 | ||
205 | /* How should editor hadle tabs in this file? Add editor commands here. | 214 | /* How should editor hadle tabs in this file? Add editor commands here. |
206 | * vim: noexpandtab sw=8 ts=8 sts=8: | 215 | * vim: noexpandtab sw=8 ts=8 sts=8: |
207 | */ | 216 | */ |
diff --git a/gammu/emb/common/device/devfunc.c b/gammu/emb/common/device/devfunc.c index d31ebbf..c58a01f 100644 --- a/gammu/emb/common/device/devfunc.c +++ b/gammu/emb/common/device/devfunc.c | |||
@@ -1,24 +1,32 @@ | |||
1 | /* Some source from Gnokii (www.gnokii.org) | ||
2 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
3 | * GNU GPL version 2 or later | ||
4 | */ | ||
5 | /* Some source from Minicom (http://alioth.debian.org/projects/minicom) | ||
6 | * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg | ||
7 | * GNU GPL version 2 | ||
8 | */ | ||
1 | 9 | ||
2 | #include <string.h> | 10 | #include <string.h> |
3 | #ifdef WIN32 | 11 | #ifdef WIN32 |
4 | # include <io.h> | 12 | # include <io.h> |
5 | #else | 13 | #else |
6 | # include <errno.h> | 14 | # include <errno.h> |
7 | # include <signal.h> | 15 | # include <signal.h> |
8 | #endif | 16 | #endif |
9 | 17 | ||
10 | #include "../gsmstate.h" | 18 | #include "../gsmstate.h" |
11 | 19 | ||
12 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE | 20 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE |
13 | #ifdef BLUETOOTH_RF_SEARCHING | 21 | #ifdef BLUETOOTH_RF_SEARCHING |
14 | 22 | ||
15 | GSM_Error bluetooth_checkservicename(GSM_StateMachine *s, char *name) | 23 | GSM_Error bluetooth_checkservicename(GSM_StateMachine *s, char *name) |
16 | { | 24 | { |
17 | if (s->ConnectionType == GCT_BLUEPHONET && strstr(name,"Nokia PC Suite")!=NULL) return ERR_NONE; | 25 | if (s->ConnectionType == GCT_BLUEPHONET && strstr(name,"Nokia PC Suite")!=NULL) return ERR_NONE; |
18 | if (s->ConnectionType == GCT_BLUEOBEX && strstr(name,"OBEX") !=NULL) return ERR_NONE; | 26 | if (s->ConnectionType == GCT_BLUEOBEX && strstr(name,"OBEX") !=NULL) return ERR_NONE; |
19 | if (s->ConnectionType == GCT_BLUEAT && strstr(name,"COM 1") !=NULL) return ERR_NONE; | 27 | if (s->ConnectionType == GCT_BLUEAT && strstr(name,"COM 1") !=NULL) return ERR_NONE; |
20 | return ERR_UNKNOWN; | 28 | return ERR_UNKNOWN; |
21 | } | 29 | } |
22 | 30 | ||
23 | #endif | 31 | #endif |
24 | #endif | 32 | #endif |
@@ -84,49 +92,49 @@ GSM_Error socket_close(GSM_StateMachine *s, int hPhone) | |||
84 | 92 | ||
85 | #ifdef ENABLE_LGPL | 93 | #ifdef ENABLE_LGPL |
86 | 94 | ||
87 | GSM_Error lock_device(const char* port, char **lock_device) | 95 | GSM_Error lock_device(const char* port, char **lock_device) |
88 | { | 96 | { |
89 | *lock_device = 0; | 97 | *lock_device = 0; |
90 | return ERR_NONE; | 98 | return ERR_NONE; |
91 | } | 99 | } |
92 | 100 | ||
93 | bool unlock_device(char **lock_file) | 101 | bool unlock_device(char **lock_file) |
94 | { | 102 | { |
95 | return true; | 103 | return true; |
96 | } | 104 | } |
97 | 105 | ||
98 | #else | 106 | #else |
99 | 107 | ||
100 | #define max_buf_len 128 | 108 | #define max_buf_len 128 |
101 | #define lock_path "/var/lock/LCK.." | 109 | #define lock_path "/var/lock/LCK.." |
102 | 110 | ||
103 | /* Lock the device. Allocated string with a lock name is returned | 111 | /* Lock the device. Allocated string with a lock name is returned |
104 | * in lock_device | 112 | * in lock_device |
105 | */ | 113 | */ |
106 | GSM_Error lock_device(const char* port, char **lock_device) | 114 | GSM_Error lock_device(const char* port, char **lock_device) |
107 | { | 115 | { |
108 | #ifndef WIN32 | 116 | #if !defined(WIN32) && !defined(DJGPP) |
109 | char *lock_file = NULL; | 117 | char *lock_file = NULL; |
110 | char buffer[max_buf_len]; | 118 | char buffer[max_buf_len]; |
111 | const char *aux; | 119 | const char *aux; |
112 | int fd, len; | 120 | int fd, len; |
113 | GSM_Errorerror = ERR_NONE; | 121 | GSM_Errorerror = ERR_NONE; |
114 | 122 | ||
115 | dbgprintf("Locking device\n"); | 123 | dbgprintf("Locking device\n"); |
116 | 124 | ||
117 | aux = strrchr(port, '/'); | 125 | aux = strrchr(port, '/'); |
118 | /* Remove leading '/' */ | 126 | /* Remove leading '/' */ |
119 | if (aux) { | 127 | if (aux) { |
120 | aux++; | 128 | aux++; |
121 | } else { | 129 | } else { |
122 | /* No / in port */ | 130 | /* No / in port */ |
123 | aux = port; | 131 | aux = port; |
124 | } | 132 | } |
125 | len = strlen(aux) + strlen(lock_path); | 133 | len = strlen(aux) + strlen(lock_path); |
126 | 134 | ||
127 | memset(buffer, 0, sizeof(buffer)); | 135 | memset(buffer, 0, sizeof(buffer)); |
128 | lock_file = calloc(len + 1, 1); | 136 | lock_file = calloc(len + 1, 1); |
129 | if (!lock_file) { | 137 | if (!lock_file) { |
130 | dbgprintf("Out of memory error while locking device\n"); | 138 | dbgprintf("Out of memory error while locking device\n"); |
131 | return ERR_MOREMEMORY; | 139 | return ERR_MOREMEMORY; |
132 | } | 140 | } |
@@ -197,49 +205,49 @@ GSM_Error lock_device(const char* port, char **lock_device) | |||
197 | } else { | 205 | } else { |
198 | dbgprintf("Unknown error with creating lockfile %s\n", lock_file); | 206 | dbgprintf("Unknown error with creating lockfile %s\n", lock_file); |
199 | error = ERR_UNKNOWN; | 207 | error = ERR_UNKNOWN; |
200 | } | 208 | } |
201 | goto failed; | 209 | goto failed; |
202 | } | 210 | } |
203 | sprintf(buffer, "%10ld gammu\n", (long)getpid()); | 211 | sprintf(buffer, "%10ld gammu\n", (long)getpid()); |
204 | write(fd, buffer, strlen(buffer)); | 212 | write(fd, buffer, strlen(buffer)); |
205 | close(fd); | 213 | close(fd); |
206 | *lock_device = lock_file; | 214 | *lock_device = lock_file; |
207 | return ERR_NONE; | 215 | return ERR_NONE; |
208 | failed: | 216 | failed: |
209 | free(lock_file); | 217 | free(lock_file); |
210 | *lock_device = 0; | 218 | *lock_device = 0; |
211 | return error; | 219 | return error; |
212 | #else | 220 | #else |
213 | *lock_device = 0; | 221 | *lock_device = 0; |
214 | return ERR_NONE; | 222 | return ERR_NONE; |
215 | #endif | 223 | #endif |
216 | } | 224 | } |
217 | 225 | ||
218 | /* Removes lock and frees memory */ | 226 | /* Removes lock and frees memory */ |
219 | bool unlock_device(char **lock_file) | 227 | bool unlock_device(char **lock_file) |
220 | { | 228 | { |
221 | #ifndef WIN32 | 229 | #if !defined(WIN32) && !defined(DJGPP) |
222 | int err; | 230 | int err; |
223 | 231 | ||
224 | if (!lock_file) { | 232 | if (!lock_file) { |
225 | dbgprintf("Cannot unlock device\n"); | 233 | dbgprintf("Cannot unlock device\n"); |
226 | return false; | 234 | return false; |
227 | } | 235 | } |
228 | err = unlink(*lock_file); | 236 | err = unlink(*lock_file); |
229 | free(*lock_file); | 237 | free(*lock_file); |
230 | *lock_file = NULL; | 238 | *lock_file = NULL; |
231 | return (err + 1); | 239 | return (err + 1); |
232 | #else | 240 | #else |
233 | return true; | 241 | return true; |
234 | #endif | 242 | #endif |
235 | } | 243 | } |
236 | 244 | ||
237 | #endif | 245 | #endif |
238 | 246 | ||
239 | int FindSerialSpeed(char *buffer) | 247 | int FindSerialSpeed(char *buffer) |
240 | { | 248 | { |
241 | switch (atoi(buffer)) { | 249 | switch (atoi(buffer)) { |
242 | case 50 : return 50; | 250 | case 50 : return 50; |
243 | case 75 : return 75; | 251 | case 75 : return 75; |
244 | case 110: return 110; | 252 | case 110: return 110; |
245 | case 134: return 134; | 253 | case 134: return 134; |
diff --git a/gammu/emb/common/device/irda/irda.c b/gammu/emb/common/device/irda/irda.c index fef50ac..e680377 100644 --- a/gammu/emb/common/device/irda/irda.c +++ b/gammu/emb/common/device/irda/irda.c | |||
@@ -1,27 +1,31 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | 1 | /* (c) 2001-2004 by Marcin Wiacek */ |
2 | /* based on some work from Ralf Thelen and MyGnokii */ | 2 | /* based on some work from Ralf Thelen and MyGnokii (www.mwiacek.com) */ |
3 | /* based on some work from Gnokii and MSDN */ | 3 | /* based on some work from MSDN */ |
4 | /* based on some work from Gnokii (www.gnokii.org) | ||
5 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
6 | * GNU GPL version 2 or later | ||
7 | */ | ||
4 | 8 | ||
5 | /* You have to include wsock32.lib library to MS VC project to compile it */ | 9 | /* You have to include wsock32.lib library to MS VC project to compile it */ |
6 | 10 | ||
7 | #include "../../gsmstate.h" | 11 | #include "../../gsmstate.h" |
8 | 12 | ||
9 | #ifdef GSM_ENABLE_IRDADEVICE | 13 | #ifdef GSM_ENABLE_IRDADEVICE |
10 | #ifndef DJGPP | 14 | #ifndef DJGPP |
11 | 15 | ||
12 | #ifndef WIN32 | 16 | #ifndef WIN32 |
13 | # include <stdlib.h> | 17 | # include <stdlib.h> |
14 | # include <unistd.h> | 18 | # include <unistd.h> |
15 | # include <stdio.h> | 19 | # include <stdio.h> |
16 | # include <fcntl.h> | 20 | # include <fcntl.h> |
17 | # include <errno.h> | 21 | # include <errno.h> |
18 | # include <string.h> | 22 | # include <string.h> |
19 | # include <sys/time.h> | 23 | # include <sys/time.h> |
20 | # include <sys/poll.h> | 24 | # include <sys/poll.h> |
21 | # include <sys/socket.h> | 25 | # include <sys/socket.h> |
22 | # include <sys/ioctl.h> | 26 | # include <sys/ioctl.h> |
23 | #else | 27 | #else |
24 | # include <windows.h> | 28 | # include <windows.h> |
25 | # include <io.h> | 29 | # include <io.h> |
26 | #endif | 30 | #endif |
27 | 31 | ||
diff --git a/gammu/emb/common/device/irda/irda_unx.h b/gammu/emb/common/device/irda/irda_unx.h index 8dbcb97..7a55273 100644 --- a/gammu/emb/common/device/irda/irda_unx.h +++ b/gammu/emb/common/device/irda/irda_unx.h | |||
@@ -1,25 +1,25 @@ | |||
1 | /* part of irda.h available in Linux kernel source */ | 1 | /* part of irda.h available in Linux kernel source (www.kernel.org) */ |
2 | 2 | ||
3 | /********************************************************************* | 3 | /********************************************************************* |
4 | * | 4 | * |
5 | * Filename: irda.h | 5 | * Filename: irda.h |
6 | * Version: | 6 | * Version: |
7 | * Description: | 7 | * Description: |
8 | * Status: Experimental. | 8 | * Status: Experimental. |
9 | * Author: Dag Brattli <dagb@cs.uit.no> | 9 | * Author: Dag Brattli <dagb@cs.uit.no> |
10 | * Created at: Mon Mar 8 14:06:12 1999 | 10 | * Created at: Mon Mar 8 14:06:12 1999 |
11 | * Modified at: Sat Dec 25 16:06:42 1999 | 11 | * Modified at: Sat Dec 25 16:06:42 1999 |
12 | * Modified by: Dag Brattli <dagb@cs.uit.no> | 12 | * Modified by: Dag Brattli <dagb@cs.uit.no> |
13 | * | 13 | * |
14 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. | 14 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. |
15 | * | 15 | * |
16 | * This program is free software; you can redistribute it and/or | 16 | * This program is free software; you can redistribute it and/or |
17 | * modify it under the terms of the GNU General Public License as | 17 | * modify it under the terms of the GNU General Public License as |
18 | * published by the Free Software Foundation; either version 2 of | 18 | * published by the Free Software Foundation; either version 2 of |
19 | * the License, or (at your option) any later version. | 19 | * the License, or (at your option) any later version. |
20 | * | 20 | * |
21 | * Neither Dag Brattli nor University of Tromsø admit liability nor | 21 | * Neither Dag Brattli nor University of Tromsø admit liability nor |
22 | * provide warranty for any of this software. This material is | 22 | * provide warranty for any of this software. This material is |
23 | * provided "AS-IS" and at no charge. | 23 | * provided "AS-IS" and at no charge. |
24 | * | 24 | * |
25 | ********************************************************************/ | 25 | ********************************************************************/ |
diff --git a/gammu/emb/common/device/serial/ser_djg.c b/gammu/emb/common/device/serial/ser_djg.c index ac9d7c8..2524187 100644 --- a/gammu/emb/common/device/serial/ser_djg.c +++ b/gammu/emb/common/device/serial/ser_djg.c | |||
@@ -1,66 +1,66 @@ | |||
1 | 1 | ||
2 | #include "../../gsmstate.h" | 2 | #include "../../gsmstate.h" |
3 | 3 | ||
4 | #ifdef GSM_ENABLE_SERIALDEVICE | 4 | #ifdef GSM_ENABLE_SERIALDEVICE |
5 | #ifdef DJGPP | 5 | #ifdef DJGPP |
6 | 6 | ||
7 | #include "../../gsmcomon.h" | 7 | #include "../../gsmcomon.h" |
8 | #include "ser_djg.h" | 8 | #include "ser_djg.h" |
9 | 9 | ||
10 | static GSM_Error serial_close(GSM_StateMachine *s) | 10 | static GSM_Error serial_close(GSM_StateMachine *s) |
11 | { | 11 | { |
12 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 12 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
13 | 13 | ||
14 | return ERR_NONE; | 14 | return ERR_NOTIMPLEMENTED; |
15 | } | 15 | } |
16 | 16 | ||
17 | static GSM_Error serial_open (GSM_StateMachine *s) | 17 | static GSM_Error serial_open (GSM_StateMachine *s) |
18 | { | 18 | { |
19 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 19 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
20 | 20 | ||
21 | return ERR_NONE; | 21 | return ERR_NOTIMPLEMENTED; |
22 | } | 22 | } |
23 | 23 | ||
24 | static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) | 24 | static GSM_Error serial_setparity(GSM_StateMachine *s, bool parity) |
25 | { | 25 | { |
26 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 26 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
27 | 27 | ||
28 | return ERR_NONE; | 28 | return ERR_NOTIMPLEMENTED; |
29 | } | 29 | } |
30 | 30 | ||
31 | static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) | 31 | static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) |
32 | { | 32 | { |
33 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 33 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
34 | 34 | ||
35 | return ERR_NONE; | 35 | return ERR_NOTIMPLEMENTED; |
36 | } | 36 | } |
37 | 37 | ||
38 | static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) | 38 | static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) |
39 | { | 39 | { |
40 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 40 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
41 | 41 | ||
42 | return ERR_NONE; | 42 | return ERR_NOTIMPLEMENTED; |
43 | } | 43 | } |
44 | 44 | ||
45 | static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) | 45 | static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) |
46 | { | 46 | { |
47 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 47 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
48 | 48 | ||
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) | 52 | static int serial_write(GSM_StateMachine *s, void *buf, size_t nbytes) |
53 | { | 53 | { |
54 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 54 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
55 | 55 | ||
56 | return 0; | 56 | return 0; |
57 | } | 57 | } |
58 | 58 | ||
59 | GSM_Device_Functions SerialDevice = { | 59 | GSM_Device_Functions SerialDevice = { |
60 | serial_open, | 60 | serial_open, |
61 | serial_close, | 61 | serial_close, |
62 | serial_setparity, | 62 | serial_setparity, |
63 | serial_setdtrrts, | 63 | serial_setdtrrts, |
64 | serial_setspeed, | 64 | serial_setspeed, |
65 | serial_read, | 65 | serial_read, |
66 | serial_write | 66 | serial_write |
diff --git a/gammu/emb/common/device/serial/ser_unx.c b/gammu/emb/common/device/serial/ser_unx.c index 2a87b11..69c7515 100644 --- a/gammu/emb/common/device/serial/ser_unx.c +++ b/gammu/emb/common/device/serial/ser_unx.c | |||
@@ -1,59 +1,83 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | /* locking device and settings all speeds by Michal Cihar */ | 2 | /* locking device and settings all speeds by Michal Cihar */ |
3 | /* based on some work from Gnokii (www.gnokii.org) | ||
4 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
5 | * GNU GPL version 2 or later | ||
6 | */ | ||
3 | 7 | ||
4 | #include "../../gsmstate.h" | 8 | #include "../../gsmstate.h" |
5 | 9 | ||
6 | #ifdef GSM_ENABLE_SERIALDEVICE | 10 | #ifdef GSM_ENABLE_SERIALDEVICE |
7 | #ifndef WIN32 | 11 | #ifndef WIN32 |
8 | #ifndef DJGPP | 12 | #ifndef DJGPP |
9 | 13 | ||
10 | #include <sys/file.h> | 14 | #include <sys/file.h> |
11 | #include <sys/time.h> | 15 | #include <sys/time.h> |
12 | #include <string.h> | 16 | #include <string.h> |
13 | #include <termios.h> | 17 | #include <termios.h> |
14 | #include <errno.h> | 18 | #include <errno.h> |
15 | 19 | ||
16 | #include "../../gsmcomon.h" | 20 | #include "../../gsmcomon.h" |
17 | #include "ser_unx.h" | 21 | #include "ser_unx.h" |
18 | 22 | ||
23 | #ifndef O_NONBLOCK | ||
24 | # define O_NONBLOCK 0 | ||
25 | #endif | ||
26 | |||
27 | #ifdef __NetBSD__ | ||
28 | # define FNONBLOCK O_NONBLOCK | ||
29 | |||
30 | # define B57600 0010001 | ||
31 | # define B115200 0010002 | ||
32 | # define B230400 0010003 | ||
33 | # define B460800 0010004 | ||
34 | # define B500000 0010005 | ||
35 | # define B576000 0010006 | ||
36 | # define B921600 0010007 | ||
37 | # define B1000000 0010010 | ||
38 | # define B1152000 0010011 | ||
39 | # define B1500000 0010012 | ||
40 | # define B2000000 0010013 | ||
41 | # define B2500000 0010014 | ||
42 | # define B3000000 0010015 | ||
43 | # define B3500000 0010016 | ||
44 | # define B4000000 0010017 | ||
45 | #endif | ||
46 | |||
19 | static GSM_Error serial_close(GSM_StateMachine *s) | 47 | static GSM_Error serial_close(GSM_StateMachine *s) |
20 | { | 48 | { |
21 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 49 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
22 | 50 | ||
23 | /* Restores old settings */ | 51 | /* Restores old settings */ |
24 | tcsetattr(d->hPhone, TCSANOW, &d->old_settings); | 52 | tcsetattr(d->hPhone, TCSANOW, &d->old_settings); |
25 | 53 | ||
26 | /* Closes device */ | 54 | /* Closes device */ |
27 | close(d->hPhone); | 55 | close(d->hPhone); |
28 | 56 | ||
29 | return ERR_NONE; | 57 | return ERR_NONE; |
30 | } | 58 | } |
31 | 59 | ||
32 | #ifndef O_NONBLOCK | ||
33 | # define O_NONBLOCK 0 | ||
34 | #endif | ||
35 | |||
36 | static GSM_Error serial_open (GSM_StateMachine *s) | 60 | static GSM_Error serial_open (GSM_StateMachine *s) |
37 | { | 61 | { |
38 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 62 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
39 | struct termios t; | 63 | struct termios t; |
40 | int i; | 64 | int i; |
41 | 65 | ||
42 | /* O_NONBLOCK MUST is required to avoid waiting for DCD */ | 66 | /* O_NONBLOCK MUST is required to avoid waiting for DCD */ |
43 | d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK); | 67 | d->hPhone = open(s->CurrentConfig->Device, O_RDWR | O_NOCTTY | O_NONBLOCK); |
44 | if (d->hPhone < 0) { | 68 | if (d->hPhone < 0) { |
45 | i = errno; | 69 | i = errno; |
46 | GSM_OSErrorInfo(s,"open in serial_open"); | 70 | GSM_OSErrorInfo(s,"open in serial_open"); |
47 | if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory | 71 | if (i == 2) return ERR_DEVICENOTEXIST; //no such file or directory |
48 | if (i == 13) return ERR_DEVICENOPERMISSION;//permission denied | 72 | if (i == 13) return ERR_DEVICENOPERMISSION;//permission denied |
49 | return ERR_DEVICEOPENERROR; | 73 | return ERR_DEVICEOPENERROR; |
50 | } | 74 | } |
51 | 75 | ||
52 | #ifdef TIOCEXCL | 76 | #ifdef TIOCEXCL |
53 | /* open() calls from other applications shall fail now */ | 77 | /* open() calls from other applications shall fail now */ |
54 | ioctl(d->hPhone, TIOCEXCL, (char *) 0); | 78 | ioctl(d->hPhone, TIOCEXCL, (char *) 0); |
55 | #endif | 79 | #endif |
56 | 80 | ||
57 | if (tcgetattr(d->hPhone, &d->old_settings) == -1) { | 81 | if (tcgetattr(d->hPhone, &d->old_settings) == -1) { |
58 | close(d->hPhone); | 82 | close(d->hPhone); |
59 | GSM_OSErrorInfo(s,"tcgetattr in serial_open"); | 83 | GSM_OSErrorInfo(s,"tcgetattr in serial_open"); |
@@ -156,88 +180,92 @@ static GSM_Error serial_setdtrrts(GSM_StateMachine *s, bool dtr, bool rts) | |||
156 | if (rts) { | 180 | if (rts) { |
157 | ioctl(d->hPhone, TIOCMBIS, &flags); | 181 | ioctl(d->hPhone, TIOCMBIS, &flags); |
158 | } else { | 182 | } else { |
159 | ioctl(d->hPhone, TIOCMBIC, &flags); | 183 | ioctl(d->hPhone, TIOCMBIC, &flags); |
160 | } | 184 | } |
161 | 185 | ||
162 | flags = 0; | 186 | flags = 0; |
163 | ioctl(d->hPhone, TIOCMGET, &flags); | 187 | ioctl(d->hPhone, TIOCMGET, &flags); |
164 | 188 | ||
165 | dbgprintf("Serial device:"); | 189 | dbgprintf("Serial device:"); |
166 | dbgprintf(" DTR is %s", flags&TIOCM_DTR?"up":"down"); | 190 | dbgprintf(" DTR is %s", flags&TIOCM_DTR?"up":"down"); |
167 | dbgprintf(", RTS is %s", flags&TIOCM_RTS?"up":"down"); | 191 | dbgprintf(", RTS is %s", flags&TIOCM_RTS?"up":"down"); |
168 | dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down"); | 192 | dbgprintf(", CAR is %s", flags&TIOCM_CAR?"up":"down"); |
169 | dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down"); | 193 | dbgprintf(", CTS is %s\n", flags&TIOCM_CTS?"up":"down"); |
170 | if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR; | 194 | if (((flags&TIOCM_DTR)==TIOCM_DTR) != dtr) return ERR_DEVICEDTRRTSERROR; |
171 | if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR; | 195 | if (((flags&TIOCM_RTS)==TIOCM_RTS) != rts) return ERR_DEVICEDTRRTSERROR; |
172 | 196 | ||
173 | return ERR_NONE; | 197 | return ERR_NONE; |
174 | } | 198 | } |
175 | 199 | ||
176 | static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) | 200 | static GSM_Error serial_setspeed(GSM_StateMachine *s, int speed) |
177 | { | 201 | { |
178 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 202 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
179 | struct termios t; | 203 | struct termios t; |
180 | int speed2 = B19200; | 204 | int speed2 = B19200; |
181 | 205 | ||
182 | if (tcgetattr(d->hPhone, &t)) { | 206 | if (tcgetattr(d->hPhone, &t)) { |
183 | GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed"); | 207 | GSM_OSErrorInfo(s,"tcgetattr in serial_setspeed"); |
184 | return ERR_DEVICEREADERROR; | 208 | return ERR_DEVICEREADERROR; |
185 | } | 209 | } |
186 | 210 | ||
187 | smprintf(s, "Setting speed to %d\n", speed); | 211 | smprintf(s, "Setting speed to %d\n", speed); |
188 | 212 | ||
189 | switch (speed) { | 213 | switch (speed) { |
190 | case 50: speed2 = B50; break; | 214 | case 50: speed2 = B50; break; |
191 | case 75: speed2 = B75; break; | 215 | case 75: speed2 = B75; break; |
192 | case 110: speed2 = B110; break; | 216 | case 110: speed2 = B110; break; |
193 | case 134: speed2 = B134; break; | 217 | case 134: speed2 = B134; break; |
194 | case 150: speed2 = B150; break; | 218 | case 150: speed2 = B150; break; |
195 | case 200: speed2 = B200; break; | 219 | case 200: speed2 = B200; break; |
196 | case 300: speed2 = B300; break; | 220 | case 300: speed2 = B300; break; |
197 | case 600: speed2 = B600; break; | 221 | case 600: speed2 = B600; break; |
198 | case 1200: speed2 = B1200; break; | 222 | case 1200: speed2 = B1200; break; |
199 | case 1800: speed2 = B1800; break; | 223 | case 1800: speed2 = B1800; break; |
200 | case 2400: speed2 = B2400; break; | 224 | case 2400: speed2 = B2400; break; |
201 | case 4800: speed2 = B4800; break; | 225 | case 4800: speed2 = B4800; break; |
202 | case 9600: speed2 = B9600; break; | 226 | case 9600: speed2 = B9600; break; |
203 | case 19200: speed2 = B19200;break; | 227 | case 19200: speed2 = B19200;break; |
204 | case 38400: speed2 = B38400;break; | 228 | case 38400: speed2 = B38400;break; |
229 | #ifdef B57600 | ||
205 | case 57600: speed2 = B57600;break; | 230 | case 57600: speed2 = B57600;break; |
206 | case 115200: speed2 = B115200;break; | 231 | case 115200: speed2 = B115200;break; |
207 | case 230400: speed2 = B230400;break; | 232 | case 230400: speed2 = B230400;break; |
208 | case 460800: speed2 = B460800;break; | 233 | case 460800: speed2 = B460800;break; |
234 | #ifdef B500000 | ||
209 | case 500000: speed2 = B500000;break; | 235 | case 500000: speed2 = B500000;break; |
210 | case 576000: speed2 = B576000;break; | 236 | case 576000: speed2 = B576000;break; |
211 | case 921600: speed2 = B921600;break; | 237 | case 921600: speed2 = B921600;break; |
212 | case 1000000: speed2 = B1000000;break; | 238 | case 1000000: speed2 = B1000000;break; |
213 | case 1152000: speed2 = B1152000;break; | 239 | case 1152000: speed2 = B1152000;break; |
214 | case 1500000: speed2 = B1500000;break; | 240 | case 1500000: speed2 = B1500000;break; |
215 | case 2000000: speed2 = B2000000;break; | 241 | case 2000000: speed2 = B2000000;break; |
216 | case 2500000: speed2 = B2500000;break; | 242 | case 2500000: speed2 = B2500000;break; |
217 | case 3000000: speed2 = B3000000;break; | 243 | case 3000000: speed2 = B3000000;break; |
218 | case 3500000: speed2 = B3500000;break; | 244 | case 3500000: speed2 = B3500000;break; |
219 | case 4000000: speed2 = B4000000; break; | 245 | case 4000000: speed2 = B4000000; break; |
246 | #endif | ||
247 | #endif | ||
220 | } | 248 | } |
221 | 249 | ||
222 | /* This should work on all systems because it is done according to POSIX */ | 250 | /* This should work on all systems because it is done according to POSIX */ |
223 | cfsetispeed(&t, speed2); | 251 | cfsetispeed(&t, speed2); |
224 | cfsetospeed(&t, speed2); | 252 | cfsetospeed(&t, speed2); |
225 | 253 | ||
226 | if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) { | 254 | if (tcsetattr(d->hPhone, TCSADRAIN, &t) == -1) { |
227 | serial_close(s); | 255 | serial_close(s); |
228 | GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed"); | 256 | GSM_OSErrorInfo(s,"tcsetattr in serial_setspeed"); |
229 | return ERR_DEVICECHANGESPEEDERROR; | 257 | return ERR_DEVICECHANGESPEEDERROR; |
230 | } | 258 | } |
231 | 259 | ||
232 | return ERR_NONE; | 260 | return ERR_NONE; |
233 | } | 261 | } |
234 | 262 | ||
235 | static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) | 263 | static int serial_read(GSM_StateMachine *s, void *buf, size_t nbytes) |
236 | { | 264 | { |
237 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 265 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
238 | struct timeval timeout2; | 266 | struct timeval timeout2; |
239 | fd_set readfds; | 267 | fd_set readfds; |
240 | int actual = 0; | 268 | int actual = 0; |
241 | 269 | ||
242 | FD_ZERO(&readfds); | 270 | FD_ZERO(&readfds); |
243 | FD_SET(d->hPhone, &readfds); | 271 | FD_SET(d->hPhone, &readfds); |
diff --git a/gammu/emb/common/device/serial/ser_w32.c b/gammu/emb/common/device/serial/ser_w32.c index 9fa0135..7d88fc7 100644 --- a/gammu/emb/common/device/serial/ser_w32.c +++ b/gammu/emb/common/device/serial/ser_w32.c | |||
@@ -1,26 +1,30 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | /* based on some work from Gnokii, MSDN and others */ | 2 | /* based on some work from MSDN and others */ |
3 | /* based on some work from Gnokii (www.gnokii.org) | ||
4 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
5 | * GNU GPL version 2 or later | ||
6 | */ | ||
3 | 7 | ||
4 | #include "../../gsmstate.h" | 8 | #include "../../gsmstate.h" |
5 | 9 | ||
6 | #ifdef GSM_ENABLE_SERIALDEVICE | 10 | #ifdef GSM_ENABLE_SERIALDEVICE |
7 | #ifdef WIN32 | 11 | #ifdef WIN32 |
8 | 12 | ||
9 | #include <windows.h> | 13 | #include <windows.h> |
10 | #include <string.h> | 14 | #include <string.h> |
11 | #include <stdio.h> | 15 | #include <stdio.h> |
12 | #include <io.h> | 16 | #include <io.h> |
13 | #include <memory.h> | 17 | #include <memory.h> |
14 | 18 | ||
15 | #include "../../gsmcomon.h" | 19 | #include "../../gsmcomon.h" |
16 | #include "ser_w32.h" | 20 | #include "ser_w32.h" |
17 | 21 | ||
18 | static GSM_Error serial_close(GSM_StateMachine *s) | 22 | static GSM_Error serial_close(GSM_StateMachine *s) |
19 | { | 23 | { |
20 | GSM_Device_SerialData *d = &s->Device.Data.Serial; | 24 | GSM_Device_SerialData *d = &s->Device.Data.Serial; |
21 | 25 | ||
22 | /* Disables all monitored events for device */ | 26 | /* Disables all monitored events for device */ |
23 | SetCommMask(d->hPhone, 0); | 27 | SetCommMask(d->hPhone, 0); |
24 | 28 | ||
25 | /* Discards all characters from input/output buffer and terminates | 29 | /* Discards all characters from input/output buffer and terminates |
26 | * pending read/write operations | 30 | * pending read/write operations |