int open_serial(char *devName) { char *serDev; if (strstr(devName, "TTYB") != NULL) serDev = "/dev/term/b"; else if (strstr(devName, "COM1") != NULL) serDev = "/dev/ttyS0"; else serDev = "/dev/term/a"; if (strstr(devName, "SMS_")) { return (initPort(serDev, SMS_SERIAL_PORT)); } else if (strstr(devName, "ASM_")) { return (initPort(serDev, SMS_SERIAL_PORT)); } else if (strstr(devName, "NMS")) { return (initPort(serDev, SMS_SERIAL_PORT)); } else if (strstr(devName, "GIL")) { return (initPort(serDev, GILSON215_SERIAL_PORT)); } else { return (initPort(serDev, SMS_SERIAL_PORT)); } }
void SerialPortComponent::dataChanged() { #if 0 QString baudString = dataString("baudRate"); unsigned baudRate = 0; if ( baudString == "B0" ) baudRate = B0; else if ( baudString == "B50" ) baudRate = B50; else if ( baudString == "B75" ) baudRate = B75; else if ( baudString == "B110" ) baudRate = B110; else if ( baudString == "B134" ) baudRate = B134; else if ( baudString == "B150" ) baudRate = B150; else if ( baudString == "B200" ) baudRate = B200; else if ( baudString == "B300" ) baudRate = B300; else if ( baudString == "B600" ) baudRate = B600; else if ( baudString == "B1200" ) baudRate = B1200; else if ( baudString == "B1800" ) baudRate = B1800; else if ( baudString == "B2400" ) baudRate = B2400; else if ( baudString == "B4800" ) baudRate = B4800; else if ( baudString == "B9600" ) baudRate = B9600; else if ( baudString == "B19200" ) baudRate = B19200; else if ( baudString == "B38400" ) baudRate = B38400; else { kError() << k_funcinfo << "Unknown baud rate = \""<<baudString<<"\""<<endl; return; } initPort( dataString("port"), baudRate ); #endif initPort( dataString("port"), B200 ); }
int main(void) { initPort(); initTimers(); static update = 0; while(1) { while (~PINC & 1) // Run while bit 0 in PINC is 0 (Invert PINC then AND with 1, this will return 1 if PINC0 was originally 0) (Check if button is pressed) { if (!update) { cli(); // Disable global interrupts PORTA = 0xFF; PORTB = 0xFF; update = 1; // Has been updated } } // If button is not pressed, continue blinking lights if (update) { update = 0; sei(); // Enable global interrupts } if (counter_A > 6) counter_A = 0; PORTA = (1 << counter_A++); // Bitshifting shenanigans, shifts one up. Ex: 0b00000010 -> 0b00000100 if (counter_B > 6) counter_B = 0; PORTB = (1 << counter_B++); // Bitshifting shenanigans, shifts one up. Ex: 0b00000010 -> 0b00000100 }; return 0; }
RotaryEncoder::RotaryEncoder( EncoderPort port, int buttonPin ) { _port = port; _buttonPin = buttonPin; pinMode( buttonPin, INPUT ); digitalWrite( buttonPin, HIGH ); initPort(); }
/********************************** * main, *********************************** * Remember to keep this short **********************************/ int main(void) { node head; // make the head node for the dynamic list start point head.prior=NULL; head.next=NULL; head_dyn_list=&head; // set the global head_dyn_list to point to start node point_dyn_list=head_dyn_list; //set point_dyn_list to point to start node initPort(); while((0 == ((PIND) & (1 << 0))) ); // wait for PIND0 to go high initTimer3(); // Init timer3 this is used for emulating a test run. initTimer(); // timer1 is used for the second counter. while((1==((PIND) & (1 << 0)))) // run until PIND0 go low { if(nyEvent.nyloper == 1) // this variable is used to signal that a new event has happened { handelNyEvent(&nyEvent); nyEvent.nyloper = 0; // reset the new event variable } } stopTimer_1(); soterEtterNummer(); // TODO this is the function that you need to write!! return 0; }
/* main function */ int main() { OSCSetPBDIV (OSC_PB_DIV_1); //configure PBDIV so PBCLK = SYSCLK initIntGlobal(); initPort(); initCN(); initPWM(); while (1); }
RobotControl::RobotControl(): port("COM1"), is_time_synced(false), is_recording(false), posTimer(this), moveTimer(this) { connect(&posTimer, SIGNAL(timeout()), this, SLOT(writePos())); connect(&moveTimer, SIGNAL(timeout()), this, SLOT(moveTimeout())); initPort(); }
bool clsYarp::initPortSend(char* portSend,char *portRcv, char* protocol) { if(!initPort(portSend)) { return false; } return connectPort(portSend,portRcv,protocol); }
/** * \brief main loop * Within the main loop the LED port(s) are initialized and toggled, using mylib. The * main loop never ends until switching off the AVR itself. */ int main(void) { initPort(); while(1) { togglePin(); } }
bool clsYarp::initPortRcv(char* portRcv,char *portSend, char* protocol) { if(!initPort(portRcv)) { WARNMSG(("Failed to initPort %s",portRcv)); return false; } return connectPort(portSend,portRcv,protocol); }
void TEDisplayBase::setPortNumberAndInit(int pn) { if (m_pWriter) ((SlowWriterThread*)m_pWriter)->stop(); setPortNumber(pn); initPort(); if (m_pWriter) { ((SlowWriterThread*)m_pWriter)->setPort(port()); ((SlowWriterThread*)m_pWriter)->start(); } };
int main() { char clkwise=1; initPort(); while(1) { int i=0,j=0; if (clkwise) { for (i=0;i<=7;i++) { for (j=0;j<5;j++) { PORTDCLR = 0x0002; PORTDSET = 0x0010; DelayMotor(); PORTDCLR = 0x0010; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0002; DelayMotor(); } DelayMsec(30); } } else { DelayMsec(30); for (i=0;i<=7;i++) { for (j=0;j<5;j++) { PORTDCLR = 0x0010; PORTDSET = 0x0002; DelayMotor(); PORTDCLR = 0x0002; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0010; DelayMotor(); } DelayMsec(30); } } } }
/*! * TEDisplayEpson is a driver class for 20x2 PTC compatible customer displays. * TEDisplayEpson(int pn) - class constructor. * pn is a com port number. */ TEDisplayEpson::TEDisplayEpson(int pn): TEDisplayBase(pn), updInterval(100),bBrightnessPending(false),bLoadCharsPending(false), bInitPending(true) { setName("TEDisplayEpson"); iInitCounter=200; iBrightness=255; m_baudRate=9600; initPort(); QTimer::singleShot(updInterval,this,SLOT(onTimer())); m_ee.addProcBinding3<TEDisplayEpson,const QString &,const QString &,const QString &>( this,&TEDisplayEpson::showText,"showText"); };
Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); timer=new QTimer(this); timeout=new QTimer(this); connect(timer,&QTimer::timeout,this,&Dialog::getVoltage); connect(timeout,&QTimer::timeout,this,&Dialog::handleTimeout); count=0; initPort(); initData(); initConnections(); initPlotStyle(); timer->start(1000); }
main(void) { // Initialisierung der Port Register initPort(); // Dco Taktquelle aktivieren mit 7.3728MHz DCO (); // UART-RS232 mit 115.2kBit/s initialisieren initUART1(); while(1) { project(); } }
/** Codel startAcquire of activity Acquire. * * Triggered by bass_start. * Yields to bass_exec, bass_ether. * Throws bass_e_nomem, bass_e_device, bass_e_hwparams, * bass_e_swparams. */ genom_event startAcquire(const char *device, uint32_t sampleRate, uint32_t nFramesPerChunk, uint32_t nChunksOnPort, bass_ids *ids, const bass_Audio *Audio, genom_context self) { int err; /* Prepare the Port */ if ((err = initPort(Audio, sampleRate, nFramesPerChunk, nChunksOnPort, self)) < 0) return_bass_exception(err); /* Start the capture */ initCapture(&(ids->cap), device, sampleRate, nFramesPerChunk); if ((err = createCapture(ids->cap)) < 0) { endCapture(&(ids->cap)); return_bass_exception(err); } return bass_exec; }
main (int argc, char *argv[]) { int done; int status; char buffer[256]; char responce[256]; char *bptr; char *cmdline; int buflen = 1; int firstentry = 1; int chars; char cmdchar; if (argc < 2) { fprintf(stdout,"usage: %s <devicename> (i.e. /dev/term/b)\n", argv[0]); exit(1); } verbose = 0; /* initialize Serial port to Gilson */ Portfd = initPort(argv[1],PATIENT_TABLE); /* need this info for isocenter calcualtions */ SoftLimits(); if (argc > 2) { cmdchar = argv[2][0]; /* printf("2nd arg: '%s'\n",argv[2]); */ if (cmdchar != '-') { status = 0; switch( toupper(cmdchar) ) { case 'M': MoveAxis(&(argv[2][1])); /* get status and clear up error bits */ Send_Cmd(statusCmd, responce); XYPos(X_AXIS); XYPos(Y_AXIS); break; case 'X': XYPos(X_AXIS); break; case 'Y': XYPos(Y_AXIS); break; case 'S': Status(); break; default: status = -1; break; } fflush(stdout); return(status); } else if (strcmp(argv[2],"-debug") == 0) { verbose = 1; } } if (verbose) fprintf(stdout,"Init Device: %s\n",argv[1]); if (verbose) PrintSet(); /* fprintf(stdout,"%lf %lf %lf %lf %lf %lf %lf %lf \n",xyMinMax[0],xyMinMax[1], xyMinMax[2],xyMinMax[3],xyMinMax[4],xyMinMax[5], MaxXYSpeed[0],MaxXYSpeed[1]); */ fflush(stdout); done = 1; while (done) { if (verbose) { fprintf(stdout,"M)ove Axis (MX+100,MY-100), S)tatus \n"); fprintf(stdout,"\nCmds: "); } else if (buflen) { if (!firstentry) fprintf(stdout,"Cmds:\n"); /* The GUI expects this prompt, verbatim */ else firstentry = 0; } /**********/ fflush(stdout); bptr = gets(buffer); buflen = strlen(buffer); if (bptr == NULL) break; switch( toupper(buffer[0]) ) { case 'M': MoveAxis(&buffer[1]); break; case 'S': Status(); break; case 'X': XYPos(X_AXIS); break; case 'Y': XYPos(Y_AXIS); break; case 'Q': done = 0; return; break; } } }
int main() { a=0;b=0;c=0; a1=0;b1=0;c1=0; first=1; start=0; int k=0; for (k=0;k<=7;k++) {ref_distance1[k]=0;ref_distance2[k]=0;cur_distance1[k]=0;cur_distance2[k]=0;} initIntGlobal(); initCN(); initTimer2(); initTimer4(); initPort(); LCD_init(); while(1) { while(start) { int i=0,j=0; for (i=1;i<=8;i++) { for (j=0;j<32;j++) { PORTDCLR = 0x0002; PORTDSET = 0x0010; DelayMotor(); PORTDCLR = 0x0010; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0002; DelayMotor(); } /////////////////////////////////////////////////////////////////////////////////////////// TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(16); a=TMR2; a1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(16); b=TMR2; b1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(16); c=TMR2; c1=TMR4; //DisplayTMR2(); //DisplayTMR4(); if ( (a<80000 || a1<80000 || b<80000 || b1<80000 || c<80000 || c1<80000)&& (b-c>500 || c-b>500 || b1-c1>500 || c1-b1>500 || a-b>500 || b-a>500 || a1-b1>500 || b1-a1>500 || a-c>500 || c-a>500 || a1-c1>500 || c1-a1>500 )) {PORTDbits.RD7=1;} DelayMsec(20); PORTDbits.RD7=0; /////////////////////////////////////////////////////////////////////////////////////////// } first=0; for (i=7;i>=0;i--) { for (j=0;j<32;j++) { PORTDCLR = 0x0010; PORTDSET = 0x0002; DelayMotor(); PORTDCLR = 0x0002; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0010; DelayMotor(); } /////////////////////////////////////////////////////////////////////////////////////////// TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(16); a=TMR2; a1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(16); b=TMR2; b1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(16); c=TMR2; c1=TMR4; //DisplayTMR2(); //DisplayTMR4(); if ( (a<80000 || a1<80000 || b<80000 || b1<80000 || c<80000 || c1<80000)&& (b-c>500 || c-b>500 || b1-c1>500 || c1-b1>500 || a-b>500 || b-a>500 || a1-b1>500 || b1-a1>500 || a-c>500 || c-a>500 || a1-c1>500 || c1-a1>500 )) {PORTDbits.RD7=1;} DelayMsec(20); PORTDbits.RD7=0; /////////////////////////////////////////////////////////////////////////////////////////// } } } }
int main() { initPWM(); a=0;b=0;c=0; a1=0;b1=0;c1=0; start=0; first=1; alm=0; motor_position=0; initIntGlobal(); initCN(); initTimer2(); initTimer4(); initPort(); LCD_init(); while(1) { while (start) { int i=0,j=0; for (i=1;i<=8;i++) { motor_position=i; for (j=0;j<32;j++) { PORTDCLR = 0x0002; PORTDSET = 0x0010; DelayMotor(); PORTDCLR = 0x0010; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0002; DelayMotor(); } /////////////////////////////////////////////////////////////////////////////////////////// TMR2=0; TMR4=0; PORTDSET=0x0220; DelayUsec(15); PORTDCLR=0x0220; DelayMsec(16); a=TMR2; a1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0220; DelayUsec(15); PORTDCLR=0x0220; DelayMsec(16); b=TMR2; b1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0220; DelayUsec(15); PORTDCLR=0x0220; DelayMsec(16); c=TMR2; c1=TMR4; //DisplayTMR2(); //DisplayTMR4(); if ( (a<80000 || a1<80000 || b<80000 || b1<80000 || c<80000 || c1<80000)&& (b-c>800 || c-b>800 || b1-c1>800 || c1-b1>800 || a-b>800 || b-a>800 || a1-b1>800 || b1-a1>800 || a-c>800 || c-a>800 || a1-c1>800 || c1-a1>800 )) {alarm(); break;} //DelayMsec(20); /////////////////////////////////////////////////////////////////////////////////////////// } if (alm) {alm=0;break;} for (i=7;i>=0;i--) { motor_position=i; for (j=0;j<32;j++) { PORTDCLR = 0x0010; PORTDSET = 0x0002; DelayMotor(); PORTDCLR = 0x0002; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0010; DelayMotor(); } /////////////////////////////////////////////////////////////////////////////////////////// TMR2=0; TMR4=0; PORTDSET=0x0220; DelayUsec(15); PORTDCLR=0x0220; DelayMsec(16); a=TMR2; a1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0220; DelayUsec(15); PORTDCLR=0x0220; DelayMsec(16); b=TMR2; b1=TMR4; TMR2=0; TMR4=0; PORTDSET=0x0220; DelayUsec(15); PORTDCLR=0x0220; DelayMsec(16); c=TMR2; c1=TMR4; //DisplayTMR2(); //DisplayTMR4(); if ( (a<80000 || a1<80000 || b<80000 || b1<80000 || c<80000 || c1<80000)&& (b-c>800 || c-b>800 || b1-c1>800 || c1-b1>800 || a-b>800 || b-a>800 || a1-b1>800 || b1-a1>800 || a-c>800 || c-a>800 || a1-c1>800 || c1-a1>800 )) {alarm(); break; } //DelayMsec(20); /////////////////////////////////////////////////////////////////////////////////////////// } //if (alm) {alm=0;break;} } } }
SystemLights::SystemLights(char port) { initPort(port); cathode = false; warning = false; }
void SIM90x_Init(const struct TRANSPORT_IF *tp) { uint32_t resp; uint32_t retry = 0; OS_ERR error; SIM90x_Transport = (struct TRANSPORT_IF*)tp; /////////////// OSTmrCreate(&IdleTimer, "IdleTimer", SYS_MsToTick(1200), SYS_MsToTick(1200), OS_OPT_TMR_ONE_SHOT, (OS_TMR_CALLBACK_PTR)0, (void*)0, &error ); /////////////// initPort(); Term_Init(SIM90x_Transport); //////////////// SIM90x_PowerUp(); while(1) { SYS_DelayMs(500); Debug(DEBUG_SIM908, "\n\nInit SIM908 retry %d times !!!! \n", retry); retry ++; // Echo mode off Debug(DEBUG_SIM908, "\nATE0; Echo mode off\n"); SIM90x_Flush(); SIM90x_WriteLine("ATE0", 1000); resp = SIM90x_WaitResponseList(1000, "OK", 0); Debug(DEBUG_SIM908, "Response: %s\n", SIM90x_ResponseBuffer); if( resp == 0 ) continue; // Disable network registration unsolicited result code Debug(DEBUG_SIM908, "\nAT+CREG=0; Network Registration \n"); SIM90x_Flush(); SIM90x_WriteLine("AT+CREG=0", 1000); resp = SIM90x_WaitResponseList(1000, "OK", 0); Debug(DEBUG_SIM908, "Response: %s\n", SIM90x_ResponseBuffer); if( resp == 0 ) continue; Debug(DEBUG_SIM908, "\nAT+CPIN? Enter PIN \n"); SIM90x_Flush(); SIM90x_WriteLine("AT+CPIN?", 1000); resp = SIM90x_WaitResponseList(1000, "+CPIN: READY", 0); Debug(DEBUG_SIM908, "Response: %s\n", SIM90x_ResponseBuffer); if( resp == 0 ) continue; break; } SIM90x_StartIdleTime(); }
void ParallelPortComponent::dataChanged() { initPort(dataString("port")); }
int main() { first=1; start=0; int k=0; for (k=0;k<=7;k++) {ref_distance1[k]=0;ref_distance2[k]=0;cur_distance1[k]=0;cur_distance2[k]=0;} initIntGlobal(); initCN(); initTimer2(); initTimer4(); initPort(); LCD_init(); while(1) { while(start) { int i=0,j=0; for (i=0;i<=7;i++) { for (j=0;j<32;j++) { PORTDCLR = 0x0002; PORTDSET = 0x0010; DelayMotor(); PORTDCLR = 0x0010; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0002; DelayMotor(); } TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(30); DisplayTMR2(); DisplayTMR4(); if (!first) {cur_distance1[i]=TMR2; cur_distance2[i]=TMR4;} else {ref_distance1[i]=TMR2;ref_distance2[i]=TMR4; cur_distance1[i]=TMR2; cur_distance2[i]=TMR4;} if (cur_distance1[i]-ref_distance1[i]>300 || ref_distance1[i]-cur_distance1[i]>300 ||cur_distance2[i]-ref_distance2[i]>300 || ref_distance2[i]-cur_distance2[i]>300) {PORTDbits.RD7=1;} DelayMsec(20); PORTDbits.RD7=0; } first=0; for (i=0;i<=7;i++) { for (j=0;j<32;j++) { PORTDCLR = 0x0010; PORTDSET = 0x0002; DelayMotor(); PORTDCLR = 0x0002; PORTDSET = 0x0004; DelayMotor(); PORTDCLR = 0x0004; PORTDSET = 0x0008; DelayMotor(); PORTDCLR = 0x0008; PORTDSET = 0x0010; DelayMotor(); } TMR2=0; TMR4=0; PORTDSET=0x0021; DelayUsec(15); PORTDCLR=0x0021; DelayMsec(30); DisplayTMR2(); DisplayTMR4(); cur_distance1[7-i]=TMR2; cur_distance2[7-i]=TMR4; if (cur_distance1[7-i]-ref_distance1[i]>300 || ref_distance1[i]-cur_distance1[7-i]>300 ||cur_distance2[7-i]-ref_distance2[i]>300 || ref_distance2[i]-cur_distance2[7-i]>300) {PORTDbits.RD7=1;} DelayMsec(20); PORTDbits.RD7=0; } } } }
main (int argc, char *argv[]) { char buffer[256]; char *bptr; int i, val; int buflen = 1; int done = 1; int verbose = 1; int stat; if (argc < 2) { fprintf(stdout,"usage: %s <devicename> (i.e. /dev/term/b)\n", argv[0]); exit(1); } if (argc > 2) { verbose = 0; } /* serialPort = initPort("/dev/term/a",SMS_SERIAL_PORT); */ serialPort = initPort(argv[1],SMS_SERIAL_PORT); write(serialPort, "\r",1); /* is NMS ready? */ stat = cmdAck(serialPort,6); if (stat == SMPTIMEOUT) { fprintf(stdout,"\nNMS_NOT_READY\n"); fflush(stdout); /*exit(1);*/ } while (done) { if (verbose) { fprintf(stdout,"D)own Probe, U)p Probe, S#)ample Number\n"); fprintf(stdout,"F)lange Adj., P)robe Actuator, A)djust Probe\n"); fprintf(stdout,"T)est NMS, R)ack Test, C)arousel Adj,\n"); fprintf(stdout,"Q)uit, \n"); fprintf(stdout,"\nEnter a command: "); } else if (buflen) { fprintf(stdout,"\nCMDS:\n"); } fflush(stdout); bptr = gets(buffer); buflen = strlen(buffer); if (bptr == NULL) break; switch( toupper(buffer[0]) ) { case 'D': robot('F',0); break; case 'U': robot('M',0); break; case 'F': robot('A',1); break; case 'P': robot('A',2); break; case 'A': robot('A',3); break; case 'T': robot('A',4); break; case 'R': robot('A',5); break; case 'C': robot('A',6); break; case 'S': val = atoi(buffer+1); robot('V', val); break; case 'ETX': robot('',0); break; case 'Q': robot('Q',0); close(serialPort); fprintf(stdout,"BYE\n"); fflush(stdout); exit(0); break; default: break; } } }