/* * Class: edu_wpi_first_wpilibj_hal_DIOJNI * Method: setDIO * Signature: (JS)V */ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO (JNIEnv *env, jclass, jlong id, jshort value) { //DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO"; //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << (void*)id; //DIOJNI_LOG(logDEBUG) << "Value = " << value; int32_t status = 0; setDIO((void*)id, value, &status); //DIOJNI_LOG(logDEBUG) << "Status = " << status; CheckStatus(env, status); }
/* * Class: edu_wpi_first_wpilibj_hal_DIOJNI * Method: setDIO * Signature: (Ljava/nio/ByteBuffer;SLjava/nio/IntBuffer;)V */ JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_DIOJNI_setDIO (JNIEnv *env, jclass, jobject id, jshort value, jobject status) { //DIOJNI_LOG(logDEBUG) << "Calling DIOJNI setDIO"; void ** javaId = (void**)env->GetDirectBufferAddress(id); //DIOJNI_LOG(logDEBUG) << "Port Ptr = " << *javaId; //DIOJNI_LOG(logDEBUG) << "Value = " << value; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); //DIOJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr; setDIO(*javaId, value, statusPtr); //DIOJNI_LOG(logDEBUG) << "Status = " << *statusPtr; }
int my_main(const char* str_latero_ip, int print_response, int npack, unsigned int* dacval, int dacval_cnt, char rd, char wr, int addr, int value, char dst_main, char dst_io, int testpattern ) { latero_conn latero; /* struct sockaddr_in si_server, si_other; int s, ii, slen=sizeof(si_other); char pktbuff[BUFLEN]; char rspbuff[BUFLEN]; */ int ii; uint8_t blades[64]; uint16_t dio_out = 0x0000; // For raw address commands uint16_t saddr = 0x0000; uint16_t sdata = 0x0000; latero_dst_device destination; int numbytes = 0; latero_pkt_t response; printf("Init Connection: "); if ( ii = init_connection( &latero, str_latero_ip ) < 0 ) { printf("Error (%d)!\n",ii ); return(-1); } else { printf("OK.\n"); } // Sanitize the dac values for(ii = 0 ; ii < 4 ; ii++ ) { if (ii < dacval_cnt ) { setDAC( &latero, ii, dacval[ii] ); } } /* for(ii = 0 ; ii<64 ; ii++ ) { blades[ii] = ii; } setBlades( &latero, blades ); */ // Run a few test cases here TestInit(); ii = 0; switch(testpattern) { case 1: TestSplit1(&latero); sleep(1); TestSplit2(&latero); break; case 2: TestAllpin(&latero); break; case 3: TestRow(&latero); sleep(1); TestCol(&latero); break; case 4: // Test continuously without stopping while(1) { printf("%d ", ii); TestRow(&latero); printf("%d ", ii); TestCol(&latero); ii++; } break; } /* Just on led is turned on... */ setDIO( &latero, 0xDEAC ); // setDAC( &latero, 0x0, 0x1234 ); // setDAC( &latero, 0x1, 0x5678 ); // setDAC( &latero, 0x2, 0x9ABC ); // setDAC( &latero, 0x3, 0xDEF0 ); printf("Sending\n"); sendNormalPacket( &latero, &response ); printf("printing\n"); printPacket( &response ); /* printf("Test Connection\n"); if( test_connection( &latero ) < 0 ) { fprintf(stderr,"The test_connection() failed\n"); } else { printf("Connection with Latero is OK.\n"); } */ if( rd > 0 || wr > 0 ) { saddr = addr & 0xFFFF; sdata = value & 0xFFFF; if ( dst_main > 0 ) { destination = LATERO_CONTROLLER; } else if ( dst_io > 0 ) { destination = LATERO_IO; } if( rd > 0 ) { rawRead( &latero, destination, saddr, &sdata ); printf("Data Read at address 0x%4.4X = 0x%4.4X\n", saddr,sdata); } else { /* Write */ rawWrite(&latero, destination, saddr, sdata ); printf("0x%4.4X written at address 0x%4.4X\n", sdata,saddr ); } } else { // Normal Latero Packets //fillNormalPacket(PKT_TYPE_FULL, dac, blades, dio_out, &packetSend); } return( close_connection( &latero ) ); }