@@ -129,7 +129,7 @@ static REBINT Set_Serial_Settings(HANDLE h, REBREQ *req)
129
129
return DR_ERROR ;
130
130
}
131
131
132
- JOIN_STR (fullpath ,req -> serial .path ,MAX_SERIAL_DEV_PATH );
132
+ JOIN_STR (fullpath ,req -> serial .path ,MAX_SERIAL_DEV_PATH - 5 ); // 5 because of "\\.\" and terminating byte
133
133
134
134
h = CreateFile (fullpath , GENERIC_READ |GENERIC_WRITE , 0 , NULL ,OPEN_EXISTING , 0 , NULL );
135
135
if (h == INVALID_HANDLE_VALUE ) {
@@ -232,7 +232,7 @@ static REBINT Set_Serial_Settings(HANDLE h, REBREQ *req)
232
232
}
233
233
234
234
#ifdef DEBUG_SERIAL
235
- printf ("write %d ret: %d\n" , req -> length , req -> actual );
235
+ printf ("write %d wrote: %lu ret: %d\n" , req -> length , result , req -> actual );
236
236
#endif
237
237
238
238
if (result < 0 ) {
@@ -241,7 +241,7 @@ static REBINT Set_Serial_Settings(HANDLE h, REBREQ *req)
241
241
return DR_ERROR ;
242
242
}
243
243
req -> actual += result ;
244
- req -> data += result ;
244
+ // req->data += result;
245
245
if (req -> actual >= req -> length ) {
246
246
Signal_Device (req , EVT_WROTE );
247
247
return DR_DONE ;
@@ -270,6 +270,21 @@ static REBINT Set_Serial_Settings(HANDLE h, REBREQ *req)
270
270
return DR_DONE ;
271
271
}
272
272
273
+ /***********************************************************************
274
+ **
275
+ */ DEVICE_CMD Modify_Serial (REBREQ * req )
276
+ /*
277
+ ***********************************************************************/
278
+ {
279
+ boolean value = req -> modify .value ;
280
+ switch (req -> modify .mode ) {
281
+ case 1 : EscapeCommFunction (req -> handle , value ? SETBREAK : CLRBREAK ); break ;
282
+ case 2 : EscapeCommFunction (req -> handle , value ? SETRTS : CLRRTS ); break ; // (request-to-send) signal
283
+ case 3 : EscapeCommFunction (req -> handle , value ? SETDTR : CLRDTR ); break ; // (data-terminal-ready) signal
284
+ }
285
+ return DR_DONE ;
286
+ }
287
+
273
288
274
289
/***********************************************************************
275
290
**
@@ -287,7 +302,7 @@ static DEVICE_CMD_FUNC Dev_Cmds[RDC_MAX] = {
287
302
0 , // poll
288
303
0 , // connect
289
304
Query_Serial ,
290
- 0 , // modify
305
+ Modify_Serial ,
291
306
0 , // create
292
307
0 , // delete
293
308
0 // rename
0 commit comments