PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Simple Libraries
Social
libbadgetools
peb_ir_receive.c
1
#include "simpletools.h"
2
#include "
badgetools.h
"
3
4
jm_ir_hdserial
*irself;
5
6
int
receive
(
char
*s)
7
{
8
int
len = 127;
9
//char buf[len];
10
memset(s, 0, len);
11
int
check =
ir_receive
(s, len);
12
if
(check)
13
len = 1 + strlen(s);
14
else
15
len = 0;
16
//memcpy(s, buf, len);
17
return
len;
18
}
19
/*
20
int receive(char *s)
21
{
22
int len = 127;
23
char buf[len];
24
memset(buf, 0, len);
25
ir_receive(buf, len);
26
len = 1 + strlen(buf);
27
memcpy(s, buf, len);
28
return len;
29
}
30
*/
31
int
ir_receive
(
char
*s,
int
ssize)
32
{
33
//ircom_rxflush();
34
//int temp = 0, checksum = 0, reps = 0;
35
int
temp = 0, checksum = 0;
36
while
(temp != STX)
37
{
38
//if((irself->rxtail == irself->rxhead)) return 0;
39
//else temp = ircom_rxtime(20);
40
temp = ircom_rxtime(20);
41
if
(temp == -1)
return
0;
42
}
43
//rgb(L, RED);
44
int
i = 0;
45
while
(1)
46
{
47
temp = ircom_rxtime(10);
48
if
(temp == ETX || temp == -1)
49
{
50
break
;
51
}
52
else
53
{
54
s[i] = (char) temp;
55
checksum += s[i++];
56
}
57
}
58
checksum %= 256;
59
temp = ircom_rxtime(10);
60
//inbox = 1;
61
//rgb(L, GREEN);
62
//rgb(R, GREEN);
63
ircom_rxflush();
64
return
(
char
) checksum == (char) temp;
65
}
66
67
/*
68
TERMS OF USE: MIT License
69
70
Permission is hereby granted, free of charge, to any person obtaining a
71
copy of this software and associated documentation files (the "Software"),
72
to deal in the Software without restriction, including without limitation
73
the rights to use, copy, modify, merge, publish, distribute, sublicense,
74
and/or sell copies of the Software, and to permit persons to whom the
75
Software is furnished to do so, subject to the following conditions:
76
77
The above copyright notice and this permission notice shall be included in
78
all copies or substantial portions of the Software.
79
80
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
81
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
82
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
83
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
84
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
86
DEALINGS IN THE SOFTWARE.
87
*/
88
ir_receive
int ir_receive(char *s, int ssize)
Receive a string with a specified maxiumum number of characters over IR.
Definition:
peb_ir_receive.c:31
jm_ir_hdserial
Definition:
badgetools.h:1427
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
receive
int receive(char *s)
Receive a character string from another badge.
Definition:
peb_ir_receive.c:6
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12