-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab5.cpp
76 lines (61 loc) · 1.46 KB
/
lab5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <predef.h>
#include <stdio.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <smarttrap.h>
#include <taskmon.h>
#include <NetworkDebug.h>
#include "error_wrapper.h"
#include "LCD.h"
#include "Keypad.h"
#include "AD.h"
#include "Stepper.h"
#include "Formdata.h"
#define MAX_COUNTER_BUFFER_LENGTH 100
extern "C" {
void UserMain(void * pd);
void DisplayLameCounter( int sock, PCSTR url );
}
extern void RegisterPost();
const char * AppName="Put your name here";
LCD myLCD;
Keypad myKeypad;
AD myAD;
Stepper myStepper;
FormData myData;
void UserMain(void * pd) {
InitializeStack();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
StartHTTP();
EnableTaskMonitor();
#ifndef _DEBUG
EnableSmartTraps();
#endif
#ifdef _DEBUG
InitializeNetworkGDB_and_Wait();
#endif
myStepper.Init(STEPPER_MODE_FULL_STEP);
myKeypad.Init(KEYPAD_POLL_MODE); // Interrupts would work too
myData.Init();
myLCD.Init();
myLCD.Clear();
myAD.Init();
RegisterPost();
iprintf("Application started\n");
while (1) {
OSTimeDly(TICKS_PER_SECOND);
}
}
void DisplayLameCounter( int sock, PCSTR url )
{
static int form_counter = 0;
char buffer[MAX_COUNTER_BUFFER_LENGTH+1];
if((sock > 0) && (url != NULL)) {
iprintf(url);
snprintf(buffer,MAX_COUNTER_BUFFER_LENGTH, "<H1>The page has been reloaded %d times. </H1>", form_counter );
form_counter++;
writestring(sock,(const char *) buffer);
}
}