@@ -18,6 +18,7 @@ Right will go to the save code dialog for the new code (if there is one)
18
18
// These need to persist between processInput calls as the serial data comes in at random points
19
19
static char curcode = 0 ;
20
20
static bool first = false;
21
+ static bool assert_next_colon = false; // Necessary for managing state
21
22
22
23
void processInput (void * context )
23
24
{
@@ -26,61 +27,76 @@ void processInput(void* context)
26
27
27
28
char out [64 ];
28
29
size_t recieved = 1 ;
29
- memset (out , 0 , 64 );
30
30
31
31
while (recieved > 0 )
32
32
{
33
+ memset (out , 0 , 64 );
33
34
recieved = furi_stream_buffer_receive (
34
35
app -> dmcomm_output_stream ,
35
36
& out ,
36
37
63 ,
37
38
5 );
38
-
39
+
39
40
if (app -> state -> waitForCode && recieved > 0 )
40
41
{
41
42
FURI_LOG_I (TAG , "DMComm Sent Data: %d <%s>" , recieved , out );
42
43
//FURI_LOG_I(TAG, "reading code");
43
44
int l = strlen (out );
44
45
for (int i = 0 ; i < l ; i ++ )
45
46
{
46
- if (out [i ] == 't' )
47
+ if (out [i ] == 't' || ( assert_next_colon && out [ i ] != ':' ) )
47
48
{ // reset for timeout and continue :(
49
+ //FURI_LOG_I(TAG, "reset codes");
48
50
curcode = 0 ;
49
51
first = true;
50
52
app -> state -> spackets = 0 ;
51
53
app -> state -> rpackets = 0 ;
52
54
furi_string_reset (app -> state -> r_code );
53
55
furi_string_reset (app -> state -> s_code );
54
56
}
55
- else if (out [i ] == 's' )
57
+ if (assert_next_colon )
58
+ assert_next_colon = false;
59
+ if (out [i ] == 's' )
56
60
{ // Starts an s code block
57
61
curcode = 's' ;
62
+ assert_next_colon = true;
63
+ //FURI_LOG_I(TAG, "read s");
58
64
if (furi_string_empty (app -> state -> s_code ))
59
65
{
60
66
furi_string_push_back (app -> state -> s_code , app -> state -> current_code [0 ]);
61
67
if (first )
62
68
{
69
+ //FURI_LOG_I(TAG, "s first");
63
70
first = false;
64
71
furi_string_push_back (app -> state -> s_code , '1' );
65
72
}
66
73
else
74
+ {
75
+ //FURI_LOG_I(TAG, "s second");
67
76
furi_string_push_back (app -> state -> s_code , '2' );
77
+ }
68
78
}
69
79
furi_string_push_back (app -> state -> s_code , '-' );
70
80
}
71
81
else if (out [i ] == 'r' )
72
82
{ // Starts an r code block
73
83
curcode = 'r' ;
84
+ assert_next_colon = true;
85
+ //FURI_LOG_I(TAG, "read r");
74
86
if (furi_string_empty (app -> state -> r_code ))
75
87
{
76
88
furi_string_push_back (app -> state -> r_code , app -> state -> current_code [0 ]);
77
89
if (first )
78
90
{
91
+ //FURI_LOG_I(TAG, "r first");
79
92
first = false;
80
93
furi_string_push_back (app -> state -> r_code , '1' );
81
94
}
82
95
else
96
+ {
97
+ //FURI_LOG_I(TAG, "r second");
83
98
furi_string_push_back (app -> state -> r_code , '2' );
99
+ }
84
100
}
85
101
furi_string_push_back (app -> state -> r_code , '-' );
86
102
}
@@ -91,7 +107,7 @@ void processInput(void* context)
91
107
if (curcode == 'r' )
92
108
furi_string_push_back (app -> state -> r_code , out [i ]);
93
109
}
94
- else if (curcode != 0 && out [i ] == ' ' )
110
+ else if (curcode != 0 && ( out [i ] == ' ' || out [ i ] == '\n' ) )
95
111
{ // If we're reading a code, a space ends it
96
112
if (curcode == 's' )
97
113
app -> state -> spackets ++ ;
0 commit comments