Rev 127 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 127 | Rev 130 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | 3 | ||
Line -... | Line 4... | ||
- | 4 | unsigned char TxBuffer[150]; |
|
- | 5 | unsigned char _TxBuffer[150]; |
|
- | 6 | ||
- | 7 | char RxBuffer[150]; |
|
Line 4... | Line 8... | ||
4 | unsigned char TxBuffer[150]; |
8 | char PrintableRxBuffer[150]; |
Line -... | Line 9... | ||
- | 9 | ||
Line 5... | Line 10... | ||
5 | unsigned char _TxBuffer[150]; |
10 | |
6 | 11 | ||
7 | 12 | int mk_socket; |
|
8 | int mk_socket; |
13 | |
Line 53... | Line 58... | ||
53 | 58 | ||
54 | 59 | ||
55 | // for (c=0;c<pt+2;c++) |
60 | // for (c=0;c<pt+2;c++) |
- | 61 | // { |
|
- | 62 | status = write(mk_socket,&TxBuffer , pt+3); |
|
56 | // { |
63 | |
57 | status = write(mk_socket,&TxBuffer , pt+3); |
64 | |
- | 65 | // printf("Send to MK %d \n" , TxBuffer[c] ); |
|
58 | // printf("Send to MK %d \n" , TxBuffer[c] ); |
66 | // } |
59 | // } |
67 | /* int i=0; |
60 | /*while(TxBuffer[i] !='\r' && i<150) |
68 | while(TxBuffer[i] !='\r' && i<150) |
61 | { |
69 | { |
62 | // TxBuffer[i]='#'; |
70 | // TxBuffer[i]='#'; |
63 | status = send(s,&TxBuffer[i] , 1, 0); |
71 | status = send(mk_socket,TxBuffer[i] , 1, 0); |
64 | printf(" +%d%c ",i,TxBuffer[i]); |
72 | printf(" +%d%c ",i,TxBuffer[i]); |
Line 65... | Line 73... | ||
65 | i++; |
73 | i++; |
66 | } |
74 | } |
67 | 75 | ||
- | 76 | // status = send(s,"\r" , 1, 0); |
|
68 | status = send(s,"\r" , 1, 0); |
77 | */ |
69 | */ |
78 | status = send(mk_socket,"\r" , 1, 0); |
Line 70... | Line -... | ||
70 | // status = send(s,"\r" , 1, 0); |
- | |
Line 71... | Line 79... | ||
71 | printf("\n"); |
79 | status = send(mk_socket,"\n" , 1, 0); |
72 | } |
- | |
Line -... | Line 80... | ||
- | 80 | printf("\n"); |
|
- | 81 | } |
|
- | 82 | ||
- | 83 | ||
- | 84 | int rx_last_length; |
|
- | 85 | ||
- | 86 | int read_from_mk() |
|
- | 87 | { |
|
- | 88 | char in_char='#'; |
|
- | 89 | int count=0; |
|
- | 90 | int r=0; |
|
- | 91 | ||
- | 92 | printf("starting read\n"); |
|
- | 93 | while(in_char!='\n') |
|
- | 94 | { |
|
- | 95 | // printf("b read\n"); |
|
- | 96 | count=read(mk_socket,&in_char,1); |
|
- | 97 | //printf("a read %d\n",count); |
|
- | 98 | if (count!=-1) |
|
- | 99 | { |
|
- | 100 | // printf("%c\n",in_char); |
|
- | 101 | RxBuffer[r]=in_char; |
|
Line -... | Line 102... | ||
- | 102 | ||
- | 103 | if (in_char!=0) |
|
- | 104 | PrintableRxBuffer[r++]=in_char; |
|
- | 105 | else |
|
- | 106 | PrintableRxBuffer[r++]='0'; |
|
- | 107 | } |
|
- | 108 | ||
- | 109 | } |
|
- | 110 | rx_last_length=r; |
|
- | 111 | PrintableRxBuffer[r++]='\0'; // terminate |
|
- | 112 | printf("done --->%s\n",PrintableRxBuffer); |
|
- | 113 | ||
- | 114 | if (RxBuffer[2]=='D') |
|
- | 115 | debug_sets++; |
|
Line 73... | Line 116... | ||
73 | 116 | ||
Line 74... | Line 117... | ||
74 | /* |
117 | return 1; |
75 | 118 | } |
|
Line 89... | Line 132... | ||
89 | str2ba( dest, &addr.rc_bdaddr ); |
132 | str2ba( dest, &addr.rc_bdaddr ); |
Line 90... | Line 133... | ||
90 | 133 | ||
91 | // connect to server |
134 | // connect to server |
Line -... | Line 135... | ||
- | 135 | status = connect(mk_socket, (struct sockaddr *)&addr, sizeof(addr)); |
|
92 | status = connect(mk_socket, (struct sockaddr *)&addr, sizeof(addr)); |
136 | |
Line 93... | Line 137... | ||
93 | 137 | printf("connection status %d\n",status); |
|
Line 94... | Line 138... | ||
94 | return status; |
138 | return status; |
Line 95... | Line 139... | ||
95 | |
139 | |
96 | } |
140 | } |
Line 117... | Line 161... | ||
117 | 161 | ||
118 | // connect to server |
162 | // connect to server |
119 | // status = connect(s, (struct sockaddr *)&addr, sizeof(addr)); |
163 | // status = connect(s, (struct sockaddr *)&addr, sizeof(addr)); |
Line -... | Line 164... | ||
- | 164 | status = connect(mk_socket,(struct sockaddr*) &sa, sizeof(struct sockaddr_in)); |
|
120 | status = connect(mk_socket,(struct sockaddr*) &sa, sizeof(struct sockaddr_in)); |
165 | |
Line 121... | Line 166... | ||
121 | 166 | printf("connection status %d\n",status); |