void main() { init(); printf("Hello!\r\n"); printf("Check: %d", NRF24_Check()); transmitter(); }
int main(int argc, char *argv[]) { /* output PIN is hardcoded for testing purposes see https://projects.drogon.net/raspberry-pi/wiringpi/pins/ for pin mapping of the raspberry pi GPIO connector */ int PIN = 0; unsigned long systemCode = atol(argv[1]); int unitCode = atoi(argv[2]); int command = atoi(argv[3]); if (wiringPiSetup () == -1) return 1; NewRemoteTransmitter transmitter(systemCode, PIN, 254); switch(command) { case 1: transmitter.sendUnit(unitCode, 1); break; case 0: transmitter.sendUnit(unitCode, 0); break; default: printf("command[%i] is unsupported\n", command); return -1; } return 0; }
void TcpServerThread::run() { Packet p; while(!isStopping()) { QThread::msleep(100); if(!dynamic_cast<TcpServer *>(transmitter())->accept(1)) continue; while(proto()->next(p, 5000) && handle(p)); } }
int main(int argc, char *argv[]) { // ./rcom <type> <port> <tries> <timeout> <framesize> <filename> if(argc < 7) { printf("ARGUMENTS ERROR\n./rcom <type> <port> <tries> <timeout> <framesize> <filename>\n"); return -1; } strcpy(linkLayer.port, argv[2]); linkLayer.numTransmissions = atoi(argv[3]); linkLayer.timeout = atoi(argv[4]); linkLayer.baudRate = 38400; if (strcmp(argv[1], "transmitter") == 0) { printf("<Transmitter>\n"); if (argc == 7) { strcpy(appLayer.filename,argv[6]); appLayer.dataSize = atoi(argv[5]); } else if(argc != 7) { printf("Wrong Arguments\n"); return -1; } appMode = TRANSMITTER; transmitter(); } else if(strcmp(argv[1], "receiver") == 0) { if(argc != 7) { printf("Wrong Arguments\n"); return -1; } printf("<Receiver>\n"); appMode = RECEIVER; strcpy(appLayer.filename,argv[6]); appLayer.dataSize = atoi(argv[5]); receiver(); } else { printf("Type should be 'receiver' or 'transmitter'\n"); return -1; } llclose(); printf("\nThe job is done."); return 0; }
int main(int argc, char *argv[]) { // argv: tipo / port / tentativas / timeout / baundrate / [ficheiro / framesize] if(argc < 6) { printf("ARGUMENTS ERROR\n./rcom type port tries timeout baundrate [file framesize]\n"); return -1; } strcpy(linkData.port, argv[2]); linkData.numTransmissions = atoi(argv[3]); linkData.timeout = atoi(argv[4]); linkData.baudRate = atoi(argv[5]); int found=1; while(found==1) { switch(linkData.baudRate) { case 2400:found=0;break; case 4800:found=0;break; case 9600:found=0;break; case 19200:found=0;break; case 38400:found=0;break; case 57600:found=0;break; case 115200:found=0;break; case 31250:found=0;break; default: { printf("Error baundrate must be (2400,4800,9600,19200,38400,57600,115200 or 31250)\n"); printf("New baundrate: "); scanf("%d",&linkData.baudRate); break; } } } if (strcmp(argv[1], "transmitter") == 0) { printf("*Transmitter*\n"); if (argc == 8) { strcpy(appData.filename,argv[6]); appData.dataSize = atoi(argv[7]); } else if(argc != 6) { printf("ARGUMENTS ERROR\n./rcom type port tries timeout baundrate [file framesize]\n"); return -1; } transmitter(); } else if(strcmp(argv[1], "receiver") == 0) { if(argc < 7) { printf("ARGUMENTS ERROR\nfilename is required\n"); return -1; } printf("*Receiver*\n"); strcpy(appData.filename,argv[6]); if(argc > 7) appData.dataSize = atoi(argv[7]); receiver(); } else { printf("ARGUMENTS ERROR\ntype should be 'receiver' or 'transmitter'\n"); return -1; } llclose(); return 0; }
int main(int argc, char **argv) { int verbose=0; int pin = 15; int dim = 10; // Just a dimming value long switch_group = 100; // Group value int switch_dev = 1; // unit device value int n=0; int m=0; if (argc < 2){ display_usage(argv[0]); return 1; } while (1) { int c; c = getopt(argc, argv, "g:hvn:p:d:?"); if (c == -1) break; switch (c) { case 'g': sscanf(optarg,"%d", &n); switch_group=n; break; case 'n': sscanf(optarg,"%d", &n ); switch_dev=n; break; case 'p': sscanf(optarg,"%d", &m ); pin=m; break; case 'd': sscanf(optarg,"%d", &m); dim=m; break; case 'v': verbose=1; break; case 'h': case '?': display_usage(argv[0]); return 1; default: abort(); } } if (wiringPiSetup () == -1) exit (1) ; pinMode (pin, OUTPUT) ; // Set group, the pin and the number of re-transmits NewRemoteTransmitter transmitter(switch_group, pin, 260, 3); if (verbose == 1) { uid_t uid, euid; if (-1 == (uid = getuid())) perror("getuid() error."); if (-1 == (euid = geteuid())) perror("geteuid() error."); fprintf(stderr, "The real UID is: %u\n", uid); fprintf(stderr, "The effective UID is: %u\n", euid); fprintf(stderr, "Calling Kaku with following parameters\n"); fprintf(stderr, "verbose: %d\n", verbose); fprintf(stderr, "pin: %d\n", pin); fprintf(stderr, "device: %d\n", switch_dev); fprintf(stderr, "value: %s\n", argv[optind]); } if (optind < argc) /* first check if it says on */ { if (verbose ==1 ) printf ("additional arguments %d\n",(argc-optind)); if ( ! strcmp(argv[optind],"on")) { transmitter.sendUnit(switch_dev,true); } else if (! strcmp(argv[optind],"off")) { transmitter.sendUnit(switch_dev,false); } else { /* so it has to be a dim value */ dim=atoi(argv[optind]); transmitter.sendDim(switch_dev,dim); } } printf("OK\n"); return 0; }
int main(void) { PaStreamParameters inputParameters, outputParameters; PaStream *stream; PaError err; callbackData data; Transmitter transmitter(FRAMES_PER_BUFFER); err = Pa_Initialize(); if( err != paNoError ) goto error; data.codec2 = codec2_create(CODEC2_MODE); data.transmitter = &transmitter; data.bufferCounter = 0; inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */ if (inputParameters.device == paNoDevice) { fprintf(stderr,"Error: No default input device.\n"); goto error; } inputParameters.channelCount = 1; inputParameters.sampleFormat = PA_SAMPLE_TYPE; inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency; inputParameters.hostApiSpecificStreamInfo = NULL; outputParameters.device = 3; //Pa_GetDefaultOutputDevice(); /* default output device */ if (outputParameters.device == paNoDevice) { fprintf(stderr,"Error: No default output device.\n"); goto error; } outputParameters.channelCount = 1; outputParameters.sampleFormat = PA_SAMPLE_TYPE; outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency; outputParameters.hostApiSpecificStreamInfo = NULL; err = Pa_OpenStream( &stream, &inputParameters, &outputParameters, SAMPLE_RATE, FRAMES_PER_BUFFER, 0, /* paClipOff, */ /* we won't output out of range samples so don't bother clipping them */ localToRemoteCallback, &data ); if( err != paNoError ) goto error; err = Pa_StartStream( stream ); if( err != paNoError ) goto error; printf("Hit ENTER to stop program.\n"); getchar(); err = Pa_CloseStream( stream ); if( err != paNoError ) goto error; printf("Finished.\n"); Pa_Terminate(); codec2_destroy(data.codec2); if(DEBUG_MODE > 0) { cout << "transmitted data:" << endl; for(int i=0; i < data.recordedBits.size(); i++) { for(int j=0; j < data.recordedBits.at(i).size(); j++) { cout << data.recordedBits.at(i).at(j); } cout << endl; } } return 0; error: Pa_Terminate(); codec2_destroy(data.codec2); fprintf( stderr, "An error occured while using the portaudio stream\n" ); fprintf( stderr, "Error number: %d\n", err ); fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); return -1; }