1 file changed +38
-35
lines changed Original file line number Diff line number Diff line change @@ -118,44 +118,47 @@ int setDTR(unsigned short level)
118
118
* Maple and Maple mini boards
119
119
*/
120
120
121
- main (int argc , char * argv [])
121
+ int main (int argc , char * argv [])
122
122
{
123
-
123
+ int ret = 0 ;
124
124
if (argc < 2 || argc > 3 )
125
125
{
126
126
printf ("Usage upload-reset <serial_device> <Optional_delay_in_milliseconds>\n\r" );
127
- return ;
128
- }
129
-
130
- if (openserial (argv [1 ]))
131
- {
132
- // Send magic sequence of DTR and RTS followed by the magic word "1EAF"
133
- setRTS (false);
134
- setDTR (false);
135
- setDTR (true);
136
-
137
- usleep (50000L );
138
-
139
- setDTR (false);
140
- setRTS (true);
141
- setDTR (true);
142
-
143
- usleep (50000L );
144
-
145
- setDTR (false);
146
-
147
- usleep (50000L );
148
-
149
- write (fd ,"1EAF" ,4 );
150
-
151
- closeserial ();
152
- if (argc == 3 )
153
- {
154
- usleep (atol (argv [2 ])* 1000L );
155
- }
156
- }
157
- else
158
- {
159
- printf ("Failed to open serial device.\n\r" );
127
+ ret = 1 ;
160
128
}
129
+ else {
130
+ if (openserial (argv [1 ]))
131
+ {
132
+ // Send magic sequence of DTR and RTS followed by the magic word "1EAF"
133
+ setRTS (false);
134
+ setDTR (false);
135
+ setDTR (true);
136
+
137
+ usleep (50000L );
138
+
139
+ setDTR (false);
140
+ setRTS (true);
141
+ setDTR (true);
142
+
143
+ usleep (50000L );
144
+
145
+ setDTR (false);
146
+
147
+ usleep (50000L );
148
+
149
+ write (fd ,"1EAF" ,4 );
150
+
151
+ closeserial ();
152
+ if (argc == 3 )
153
+ {
154
+ usleep (atol (argv [2 ])* 1000L );
155
+ }
156
+ }
157
+ else
158
+ {
159
+ printf ("Failed to open serial device.\n\r" );
160
+ ret = 2 ;
161
+ }
162
+ }
163
+ return ret ;
161
164
}
0 commit comments