Wavecom OpenAT FTP serial data is project number 380098
posted at Freelancer.com. Click here to post your own project.
Bid Count: 3
Average Bid:
$ 633
02/08/2009 at 6:47 EST
Project Creator:
sealandtech
Employer Rating: (No Feedback Yet)
02/03/2009 at 20:48 EST:
Main source code:
#include "adl_global.h"
#include "wip.h"
#include "adl_rtc.h"
#define DST_SERVER "209.90.82.23"
#define DST_USER "datataker"
#define DST_PASSWORD "password"
#define DST_FILENAME "data.txt"
#define DST_ISPASSIVE TRUE
#define BKSP '\x08'
#define BKSPSEQ "\x08 \x08"
#define USED_FLOW ADL_FCM_FLOW_V24_UART1
s32 retVal;
adl_rtcTime_t presentTimeAndDate;
bool bFCMIsReady = TRUE;
ascii * buffer;
ascii * buffer2;
ascii * tempBuffer;
ascii * file_name;
static u16 tempLength;
static s8 V24Handle;
static int offset = 0;
static wip_channel_t
dst_ftp_cx = NULL,
dst_data = NULL;
u16 bufferLength;
static void evh_cx( wip_event_t *ev, void *ctx);
static void evh_data( wip_event_t *ev, void *ctx);
bool V24DataHandler ( u16 Length, u8 * Data );
bool V24CtrlHandler ( u8 Event );
void HelloWorld_TimerHandler ( u8 ID );
void appli_entry_point()
{
bufferLength = 0;
buffer = adl_memGet( 20000* sizeof(ascii) );
tempBuffer = adl_memGet( 20000* sizeof(ascii) );
file_name = adl_memGet( 20000* sizeof(ascii) );
TRACE (( 1, "fcm subscribe" ));
V24Handle = adl_fcmSubscribe ( USED_FLOW, V24CtrlHandler, V24DataHandler );
TRACE (( 1, "timer subscribe" ));
adl_tmrSubscribe ( TRUE, 600, ADL_TMR_TYPE_100MS, HelloWorld_TimerHandler );
}
static void evh_cx( wip_event_t *ev, void *ctx)
{
switch( ev->kind)
{
case WIP_CEV_OPEN:
wm_sprintf ( (file_name),"%d%d.%d%d.txt",presentTimeAndDate.Month,presentTimeAndDate.Day,presentTimeAndDate.Hour,presentTimeAndDate.Minute);
TRACE (( 1, "Make new file up FTP connection" ));
dst_data = wip_putFile( dst_ftp_cx, file_name, evh_data, NULL);
if( ! dst_data) { wip_debug( "Can't create data channel"); return; }
break;
case WIP_CEV_ERROR:
break;
case WIP_CEV_PEER_CLOSE:
break;
}
}
static void evh_data( wip_event_t *ev, void *ctx)
{
switch( ev->kind)
{
case WIP_CEV_OPEN:
wip_setOpts(dst_data, WIP_COPT_SND_BUFSIZE, 30000,WIP_COPT_SND_LOWAT,3000, WIP_COPT_END );
break;
case WIP_CEV_WRITE:
{
int nwrite = wip_write( dst_data, buffer, tempLength);
//wip_close( dst_data); //dst_data = NULL;
//wip_close( dst_ftp_cx); //dst_ftp_cx = NULL;
//adl_memRelease ( buffer );
tempLength = 0;
}
break;
case WIP_CEV_ERROR:
break;
}
}
bool V24CtrlHandler ( u8 Event )
{
bool bReturn = TRUE;
s32 sReturn;
TRACE (( 1, "serial event %d", Event ));
switch ( Event )
{
case ADL_FCM_EVENT_FLOW_OPENNED :
sReturn = adl_fcmSwitchV24State ( V24Handle, ADL_FCM_V24_STATE_DATA );
TRACE (( 1, "serial switch to datamode %d ", sReturn ));
bFCMIsReady = TRUE;
break;
case ADL_FCM_EVENT_RESUME :
break;
case ADL_FCM_EVENT_MEM_RELEASE :
break;
}
return bReturn;
}
bool V24DataHandler ( u16 Length, u8 * Data )
{
retVal = adl_rtcGetTime(&presentTimeAndDate);
TRACE (( 1, "Serial data event"));
TRACE (( 1, "tt %d", presentTimeAndDate.Year ));
wm_memcpy ( ( ascii * ) (buffer + tempLength), ( ascii * ) Data, Length);
tempLength += Length;
return TRUE;
}
void HelloWorld_TimerHandler ( u8 ID )
{
TRACE (( 1, "Timer trigger" ));
TRACE (( 1, "Connect to FTP" ));
dst_ftp_cx = wip_FTPCreateOpts (
DST_SERVER, evh_cx, NULL,
WIP_COPT_USER, DST_USER,
WIP_COPT_PASSWORD, DST_PASSWORD,
WIP_COPT_PASSIVE, DST_ISPASSIVE,
WIP_COPT_END);
}
/*
16 C811 70802 2008 3 28 12 21 52 3 0 1 2
40 200 100 10 1
0 0 0 2886 17424 0 0 0 0 0 15425
0 0 0 0 61 191 65 193 14 16 18 0 110 192 0 107
1 -1399 -2174 -172 0 0 0 129 131 162
2 -1412 -2378 -294 0 0 0 115 119 136
3 -2078 -1699 -211 0 0 0 115 107 118
4 -1839 -1868 -230 0 0 0 114 118 103
5 -1418 -2299 -333 0 0 0 109 124 104
6 -1778 -1971 -472 0 0 0 79 115 112
7 -1688 -1862 -289 0 0 0 120 95 109
8 -1675 -1995 -358 0 0 0 106 96 115
9 -986 -1709 -324 0 0 0 90 105 102
10 -1246 -1961 -422 0 0 0 87 104 94
11 -1399 -2030 -301 0 0 0 83 95 95
12 -1258 -775 -99 0 0 0 80 95 72
13 -992 -1405 -407 0 0 0 84 94 74
14 -1691 -1885 -484 0 0 0 82 99 83
15 -1603 -1586 -245 0 0 0 80 102 99
16 -1536 -1425 -239 0 0 0 87 91 102
17 -1266 -1690 -232 0 0 0 90 92 100
18 -1814 -1267 -326 0 0 0 65 69 96
19 -1379 -1944 -336 0 0 0 77 67 74
20 -1585 -1822 -495 0 0 0 56 61 54
21 -2084 -1354 -425 0 0 0 82 52 59
22 -1368 -1815 -126 0 0 0 61 63 66
23 -837 -1383 -436 0 0 0 45 58 66
24 -1608 -1715 -397 0 0 0 57 68 49
25 -1775 -1619 -282 0 0 0 47 56 59
26 -1445 -1433 -285 0 0 0 41 39 52
27 -1030 -1451 -256 0 0 0 40 43 46
28 -1248 -1572 -313 0 0 0 51 41 38
29 -1368 -2256 -160 0 0 0 39 43 49
30 -1256 -2065 -164 0 0 0 31 38 46
31 -1615 -2036 -278 0 0 0 29 32 38
32 -1926 -1847 3 0 0 0 50 23 44
33 -1281 -2289 -280 0 0 0 110 66 30
34 -1436 -1745 -343 0 0 0 75 137 32
35 -1763 -1328 -356 0 0 0 15 55 35
36 6009 -2757 -1856 0 0 0 13 13 67
37 -1235 1269 -1493 0 0 0 13 16 120
38 4405 -645 -2062 0 0 0 13 11 78
39 -2618 957 -1234 0 0 0 15 13 22
40 -1753 10311 499 0 0 0 15 14 22
*/
|
Job Type |
|