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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
diff -u --new-file -r ../R1/examples/freebsd/Makefile ./examples/freebsd/Makefile
--- ../R1/examples/freebsd/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/Makefile Tue Jan 4 21:25:14 2000
@@ -0,0 +1,3 @@
+SUBDIR= lib mweather thermodl thermos tstfind tstmlan tstmlane
+
+.include <bsd.subdir.mk>
diff -u --new-file -r ../R1/examples/freebsd/lib/Makefile ./examples/freebsd/lib/Makefile
--- ../R1/examples/freebsd/lib/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/lib/Makefile Tue Jan 4 21:40:23 2000
@@ -0,0 +1,28 @@
+
+MLANDIR= ${.CURDIR}/../../../source/lib/userial
+.PATH: ${.CURDIR} ${MLANDIR}
+LIB= mlan
+CFLAGS= -I. -DUCHAR -Wall
+NOPROFILE= yes
+PREFIX?= /usr/local
+LIBDIR= ${PREFIX}/lib
+
+SRCS= mlanfile.c mlanllu.c mlannetu.c mlansesu.c mlantrnu.c
+SRCS+= ds2480ut.c
+SRCS+= serial.c
+
+serial.c: mlan.h
+
+CLEANFILES+= mlan.h
+
+beforedepend: mlan.h
+ @true
+
+mlan.h: ${MLANDIR}/mlan.h
+ cp ${MLANDIR}/mlan.h .
+
+beforeinstall:
+ ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} mlan.h ${DESTDIR}/${PREFIX}/include
+
+.include <bsd.lib.mk>
diff -u --new-file -r ../R1/examples/freebsd/lib/serial.c ./examples/freebsd/lib/serial.c
--- ../R1/examples/freebsd/lib/serial.c Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/lib/serial.c Tue Jan 4 21:22:19 2000
@@ -0,0 +1,202 @@
+//---------------------------------------------------------------------------
+// Copyright (C) 1999 Dallas Semiconductor Corporation, All Rights Reserved.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
+// OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+// Except as contained in this notice, the name of Dallas Semiconductor
+// shall not be used except as stated in the Dallas Semiconductor
+// Branding Policy.
+//---------------------------------------------------------------------------
+//
+// TODO.C - COM functions required by MLANLL.C, MLANTRNU, MLANNETU.C and
+// MLanFile.C for MLANU to communicate with the DS2480 based
+// Universal Serial Adapter 'U'. Fill in the platform specific code.
+//
+// Version: 1.03
+//
+// History: 1.00 -> 1.01 Added function msDelay.
+//
+// 1.01 -> 1.02 Changed to generic OpenCOM/CloseCOM for easier
+// use with other platforms.
+//
+// 1.02 -> 1.03 Removed caps in #includes for Linux capatibility
+// Add function msGettick()
+//
+
+#include "mlan.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/time.h>
+
+// exportable functions required for
+// MLANLL.C, MLANTRNU, or MLANNETU.C
+void FlushCOM(void);
+int WriteCOM(int, uchar *);
+int ReadCOM(int, uchar *);
+void BreakCOM(void);
+void msDelay(int);
+void SetBaudCOM(int);
+int OpenCOM(char *);
+void CloseCOM(void);
+long msGettick(void);
+
+static int dsfd;
+static struct termios pstio;
+
+//---------------------------------------------------------------------------
+// Description:
+// flush the rx and tx buffers
+//
+void FlushCOM(void)
+{
+ tcflush(dsfd, TCIOFLUSH);
+}
+
+
+//--------------------------------------------------------------------------
+// Write an array of bytes to the COM port, verify that it was
+// sent out. Assume that baud rate has been set.
+//
+// Returns 1 for success and 0 for failure
+//
+int WriteCOM(int outlen, uchar *outbuf)
+{
+
+ if (outlen == write(dsfd, outbuf, outlen))
+ return 1;
+ return 0;
+}
+
+
+//--------------------------------------------------------------------------
+// Read an array of bytes to the COM port, verify that it was
+// sent out. Assume that baud rate has been set.
+//
+// Returns number of characters read
+//
+int ReadCOM(int inlen, uchar *inbuf)
+{
+ int i, j;
+
+ for(j = 0; j < inlen; ) {
+ i = read(dsfd, inbuf + j, inlen -j);
+ if (i <= 0)
+ break;
+ j += i;
+ }
+ return j;
+}
+
+
+//--------------------------------------------------------------------------
+// Description:
+// Send a break on the com port for at least 2 ms
+//
+void BreakCOM(void)
+{
+ tcsendbreak(dsfd, 1);
+}
+
+
+//--------------------------------------------------------------------------
+// Description:
+// Delay for at least 'len' ms
+//
+void msDelay(int len)
+{
+ usleep(len * 10000);
+}
+
+
+//--------------------------------------------------------------------------
+// Set the baud rate on the com port. The possible baud rates for
+// 'new_baud' are:
+//
+// PARMSET_9600 0x00
+// PARMSET_19200 0x02
+// PARMSET_57600 0x04
+// PARMSET_115200 0x06
+//
+void SetBaudCOM(int new_baud)
+{
+ switch (new_baud) {
+ case 0x00 /* PARMSET_9600 */: cfsetspeed(&pstio, B9600); break;
+ case 0x02 /* PARMSET_19200 */: cfsetspeed(&pstio, B19200); break;
+ case 0x04 /* PARMSET_57600 */: cfsetspeed(&pstio, B57600); break;
+ case 0x06 /* PARMSET_115200 */: cfsetspeed(&pstio, B115200); break;
+ }
+ tcsetattr(dsfd, TCSANOW, &pstio);
+}
+
+
+//---------------------------------------------------------------------------
+// Attempt to open a com port.
+// Set the starting baud rate to 9600.
+//
+// 'port_zstr' - zero terminate port name. Format is platform
+// dependent.
+//
+// Returns: TRUE - success, COM port opened
+//
+int OpenCOM(char *port_zstr)
+{
+ int i;
+
+ dsfd = open(port_zstr, O_RDWR, 0);
+ if (dsfd < 0)
+ return (0);
+ i = tcgetattr(dsfd, &pstio);
+ if (i < 0) {
+ close(dsfd);
+ return (0);
+ }
+ cfmakeraw(&pstio);
+ pstio.c_cc[VTIME] = 20;
+ pstio.c_cc[VMIN] = 0;
+ cfsetspeed(&pstio, B9600);
+ i = tcsetattr(dsfd, TCSANOW, &pstio);
+ if (i < 0) {
+ close(dsfd);
+ return (0);
+ }
+ return 1;
+}
+
+
+//---------------------------------------------------------------------------
+// Closes the connection to the port.
+//
+void CloseCOM(void)
+{
+ close(dsfd);
+}
+
+
+//--------------------------------------------------------------------------
+// Get the current millisecond tick count. Does not have to represent
+// an actual time, it just needs to be an incrementing timer.
+//
+long msGettick(void)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
+}
diff -u --new-file -r ../R1/examples/freebsd/mweather/Makefile ./examples/freebsd/mweather/Makefile
--- ../R1/examples/freebsd/mweather/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/mweather/Makefile Tue Jan 4 21:39:47 2000
@@ -0,0 +1,17 @@
+
+PROG= mweather
+
+PREFIX?= /usr/local
+BINDIR= ${PREFIX}/bin
+MLANDIR= ${.CURDIR}/../../../source/
+MLANLIB= ${.CURDIR}/../lib
+.PATH: ${MLANDIR}/apps/${PROG}
+CFLAGS= -I${MLANLIB} -DUCHAR -Wall
+LDADD= -L${MLANLIB} -lmlan
+DPADD= ${MLANLIB}/libmlan.a
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} /dev/cuaa0
+
+.include <bsd.prog.mk>
diff -u --new-file -r ../R1/examples/freebsd/thermodl/Makefile ./examples/freebsd/thermodl/Makefile
--- ../R1/examples/freebsd/thermodl/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/thermodl/Makefile Tue Jan 4 21:39:51 2000
@@ -0,0 +1,18 @@
+
+PROG= thermodl
+SRCS= thermodl.c thermout.c
+
+PREFIX?= /usr/local
+BINDIR= ${PREFIX}/bin
+MLANDIR= ${.CURDIR}/../../../source/
+MLANLIB= ${.CURDIR}/../lib
+.PATH: ${MLANDIR}/apps/thermo
+CFLAGS= -I${MLANLIB} -DUCHAR -Wall
+LDADD= -L${MLANLIB} -lmlan
+DPADD= ${MLANLIB}/libmlan.a
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} /dev/cuaa0
+
+.include <bsd.prog.mk>
diff -u --new-file -r ../R1/examples/freebsd/thermos/Makefile ./examples/freebsd/thermos/Makefile
--- ../R1/examples/freebsd/thermos/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/thermos/Makefile Tue Jan 4 21:39:51 2000
@@ -0,0 +1,18 @@
+
+PROG= thermoms
+SRCS= thermoms.c thermout.c
+
+PREFIX?= /usr/local
+BINDIR= ${PREFIX}/bin
+MLANDIR= ${.CURDIR}/../../../source/
+MLANLIB= ${.CURDIR}/../lib
+.PATH: ${MLANDIR}/apps/thermo
+CFLAGS= -I${MLANLIB} -DUCHAR -Wall
+LDADD= -L${MLANLIB} -lmlan
+DPADD= ${MLANLIB}/libmlan.a
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} /dev/cuaa0
+
+.include <bsd.prog.mk>
diff -u --new-file -r ../R1/examples/freebsd/tstfind/Makefile ./examples/freebsd/tstfind/Makefile
--- ../R1/examples/freebsd/tstfind/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/tstfind/Makefile Tue Jan 4 21:39:31 2000
@@ -0,0 +1,17 @@
+
+PROG= tstfind
+
+PREFIX?= /usr/local
+BINDIR= ${PREFIX}/bin
+MLANDIR= ${.CURDIR}/../../../source/
+MLANLIB= ${.CURDIR}/../lib
+.PATH: ${MLANDIR}/apps/${PROG}
+CFLAGS= -I${MLANLIB} -DUCHAR -Wall
+LDADD= -L${MLANLIB} -lmlan
+DPADD= ${MLANLIB}/libmlan.a
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} /dev/cuaa0
+
+.include <bsd.prog.mk>
diff -u --new-file -r ../R1/examples/freebsd/tstmlan/Makefile ./examples/freebsd/tstmlan/Makefile
--- ../R1/examples/freebsd/tstmlan/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/tstmlan/Makefile Tue Jan 4 21:39:57 2000
@@ -0,0 +1,17 @@
+
+PROG= tstmlan
+
+PREFIX?= /usr/local
+BINDIR= ${PREFIX}/bin
+MLANDIR= ${.CURDIR}/../../../source/
+MLANLIB= ${.CURDIR}/../lib
+.PATH: ${MLANDIR}/apps/${PROG}
+CFLAGS= -I${MLANLIB} -DUCHAR -Wall
+LDADD= -L${MLANLIB} -lmlan
+DPADD= ${MLANLIB}/libmlan.a
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} /dev/cuaa0
+
+.include <bsd.prog.mk>
diff -u --new-file -r ../R1/examples/freebsd/tstmlane/Makefile ./examples/freebsd/tstmlane/Makefile
--- ../R1/examples/freebsd/tstmlane/Makefile Thu Jan 1 01:00:00 1970
+++ ./examples/freebsd/tstmlane/Makefile Tue Jan 4 21:40:03 2000
@@ -0,0 +1,17 @@
+
+PROG= tstmlane
+
+PREFIX?= /usr/local
+BINDIR= ${PREFIX}/bin
+MLANDIR= ${.CURDIR}/../../../source/
+MLANLIB= ${.CURDIR}/../lib
+.PATH: ${MLANDIR}/apps/${PROG}
+CFLAGS= -I${MLANLIB} -DUCHAR -Wall
+LDADD= -L${MLANLIB} -lmlan
+DPADD= ${MLANLIB}/libmlan.a
+NOMAN= 1
+
+test: ${PROG}
+ ./${PROG} /dev/cuaa0
+
+.include <bsd.prog.mk>
|