1313import com .neuronrobotics .sdk .dyio .DyIO ;
1414import com .neuronrobotics .sdk .dyio .DyIOChannelMode ;
1515import com .neuronrobotics .sdk .serial .SerialConnection ;
16+ import com .neuronrobotics .sdk .util .ThreadUtil ;
1617
1718public class DyIONamespaceTest {
1819
@@ -101,6 +102,7 @@ public void shutdownDevices(){
101102 for (int i =0 ;i <modes .size ();i ++){
102103 assertTrue (modes .get (i )==modesAfter .get (i ));
103104 assertTrue (modes .get (i )==testDevice .getMode (i ));
105+ testDevice .setMode (i , DyIOChannelMode .DIGITAL_IN );
104106 }
105107 }
106108 @ Test public void DyIOInputTest (){
@@ -119,11 +121,13 @@ public void shutdownDevices(){
119121 for (int j =0 ;j <5 ;j ++){
120122 int pinState = state ?1 :0 ;
121123 harness .setValue (testerIndex , pinState );
124+ ThreadUtil .wait (50 );
122125 int gotValue = testDevice .getValue (i );
123126 System .out .println (" Pin:" +i +" Tester:" +testerIndex +" setting to: " +pinState +" got:" +gotValue );
124127 assertTrue (gotValue ==pinState );
125128 state = !state ;
126129 }
130+ harness .setMode (testerIndex , DyIOChannelMode .DIGITAL_IN );
127131 }
128132 }
129133
@@ -136,20 +140,23 @@ public void shutdownDevices(){
136140
137141 //test device as output
138142 for (int i =0 ;i <numPins ;i ++){
139- if (!(i ==16 || i ==17 )){
140- int testerIndex = numPins -1 -i ;
143+ int testerIndex = numPins -1 -i ;
144+ if (!(testerIndex ==16 || testerIndex ==17 )){
145+
141146 harness .setMode (testerIndex , DyIOChannelMode .DIGITAL_IN );
142147 testDevice .setMode (i , DyIOChannelMode .DIGITAL_OUT );
143148
144149 boolean state =true ;
145150 for (int j =0 ;j <5 ;j ++){
146151 int pinState = state ?1 :0 ;
147152 testDevice .setValue (i , pinState );
153+ ThreadUtil .wait (200 );
148154 int gotValue = harness .getValue (testerIndex );
149155 System .out .println (" Pin:" +i +" Tester:" +testerIndex +" setting to: " +pinState +" got:" +gotValue );
150156 assertTrue (gotValue ==pinState );
151157 state = !state ;
152158 }
159+ testDevice .setMode (i , DyIOChannelMode .DIGITAL_IN );
153160 }
154161 }
155162
0 commit comments