X-Git-Url: http://git.jankratochvil.net/?p=gnokii.git;a=blobdiff_plain;f=common%2Flinks%2Fatbus.c;fp=common%2Flinks%2Fatbus.c;h=afe791629069934fc2276b065b41aa3a28ac4f1c;hp=0af3d2076a394c924e92b151ad06968d8f99f932;hb=1379b6d01c3c3bd082a8ab32433450d8a2f3419c;hpb=a363234939c6030f24d092e9d4d97ee40f50ce03 diff --git a/common/links/atbus.c b/common/links/atbus.c index 0af3d20..afe7916 100644 --- a/common/links/atbus.c +++ b/common/links/atbus.c @@ -11,11 +11,8 @@ Released under the terms of the GNU GPL, see file COPYING for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:09 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.5 2001/11/19 13:03:18 pkot - nk3110.c cleanup + Revision 1.1.1.2 2002/04/03 00:08:07 short + Found in "gnokii-working" directory, some November-patches version Revision 1.4 2001/09/09 21:45:49 machek Cleanups from Ladislav Michl : @@ -63,19 +60,14 @@ /* FIXME - win32 stuff! */ -/* FIXME - when sending an AT command while another one is still in */ -/* progress, the old command is aborted and the new ignored. */ -/* the result is _one_ error message from the phone. */ - /* Some globals */ -/* FIXME - if we use more than one phone these should be part of */ -/* a statemachine. */ - +static GSM_Link *glink; static GSM_Statemachine *statemachine; static int binlength = 0; static char reply_buf[1024]; static int reply_buf_pos = 0; + static int xwrite(unsigned char *d, int len) { int res; @@ -114,7 +106,7 @@ void ATBUS_RX_StateMachine(unsigned char rx_char) if (reply_buf_pos >= binlength) { if (((reply_buf_pos > 3) && (!strncmp(reply_buf+reply_buf_pos-4, "OK\r\n", 4))) || ((reply_buf_pos > 6) && (!strncmp(reply_buf+reply_buf_pos-7, "ERROR\r\n", 7)))) { - SM_IncomingFunction(statemachine, statemachine->LastMsgType, reply_buf, reply_buf_pos); + SM_IncomingFunction(statemachine, 1, reply_buf, reply_buf_pos); reply_buf_pos = 0; binlength = 0; return; @@ -131,10 +123,10 @@ void ATBUS_RX_StateMachine(unsigned char rx_char) } -bool ATBUS_OpenSerial(int hw_handshake, char *device) +bool ATBUS_OpenSerial(int hw_handshake) { int result; - result = device_open(device, false, false, hw_handshake, GCT_Serial); + result = device_open(glink->PortDevice, false, false, hw_handshake, GCT_Serial); if (!result) { perror(_("Couldn't open ATBUS device")); return (false); @@ -179,14 +171,15 @@ GSM_Error ATBUS_Initialise(GSM_Statemachine *state, int hw_handshake) setvbuf(stderr, NULL, _IONBF, 0); /* 'Copy in' the global structures */ + glink = &(state->Link); statemachine = state; /* Fill in the link functions */ - state->Link.Loop = &ATBUS_Loop; - state->Link.SendMessage = &AT_SendMessage; + glink->Loop = &ATBUS_Loop; + glink->SendMessage = &AT_SendMessage; - if (state->Link.ConnectionType == GCT_Serial) { - if (!ATBUS_OpenSerial(hw_handshake, state->Link.PortDevice)) + if (glink->ConnectionType == GCT_Serial) { + if (!ATBUS_OpenSerial(hw_handshake)) return GE_DEVICEOPENFAILED; } else { fprintf(stderr, "Device not supported by ATBUS");