@@ -9,9 +9,11 @@ import {
99 fork ,
1010 put ,
1111 race ,
12+ select ,
1213 take ,
1314 takeEvery ,
1415} from 'typed-redux-saga/macro' ;
16+ import { RootState } from '../reducers' ;
1517import { ensureError , hex } from '../utils' ;
1618import {
1719 didFailToSendCommand ,
@@ -35,6 +37,7 @@ import {
3537import {
3638 EventType ,
3739 ProtocolError ,
40+ createLegacyStartUserProgramCommand ,
3841 createStartReplCommand ,
3942 createStartUserProgramCommand ,
4043 createStopUserProgramCommand ,
@@ -53,6 +56,7 @@ import {
5356 * the bytecodes to to the device.
5457 */
5558function * encodeRequest ( ) : Generator {
59+ const { useLegacyStartUserProgram } = yield * select ( ( s : RootState ) => s . hub ) ;
5660 // Using a loop to serialize sending data to avoid "busy" errors.
5761
5862 const chan = yield * actionChannel (
@@ -68,9 +72,15 @@ function* encodeRequest(): Generator {
6872 if ( sendStopUserProgramCommand . matches ( action ) ) {
6973 yield * put ( writeCommand ( action . id , createStopUserProgramCommand ( ) ) ) ;
7074 } else if ( sendStartUserProgramCommand . matches ( action ) ) {
71- yield * put (
72- writeCommand ( action . id , createStartUserProgramCommand ( action . slot ) ) ,
73- ) ;
75+ if ( useLegacyStartUserProgram ) {
76+ yield * put (
77+ writeCommand ( action . id , createLegacyStartUserProgramCommand ( ) ) ,
78+ ) ;
79+ } else {
80+ yield * put (
81+ writeCommand ( action . id , createStartUserProgramCommand ( action . slot ) ) ,
82+ ) ;
83+ }
7484 } else if ( sendStartReplCommand . matches ( action ) ) {
7585 yield * put ( writeCommand ( action . id , createStartReplCommand ( ) ) ) ;
7686 } else if ( sendWriteUserProgramMetaCommand . matches ( action ) ) {
0 commit comments