Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int _tmain(int argc, _TCHAR* argv[])
- {
- initPhysics();
- initGraphics();
- initStatic();
- printf("Welcome to the serial test app!\n\n");
- Serial* SP = new Serial("COM3"); /* CHANGE COM PORT TO THE ONE THE ARDUINO IS CONNECTED TO*/
- if (SP->IsConnected()) /*Check connection to port*/
- printf("We're connected");
- else return 0;
- SPageFilePhysics* pf = (SPageFilePhysics*)m_physics.mapFileBuffer; /*Pointer used to access physics data*/
- char Data[256]="";
- int DataLength = 255;
- while (true)
- {
- //printf("Speed : %f \n", pf->speedKmh);
- snprintf(Data, sizeof(Data), "%3.3f", pf->speedKmh); /*Float to char conversion, to send it through the serial port*/
- SP->WriteData(Data, DataLength); /*Write data on Serial Port*/
- while (SP->ReadData(inData, sizeof(inData)) != 1); /*Wait for response*/
- printf("Speed KmH : %s\n", Data);
- std::this_thread::sleep_for(std::chrono::milliseconds(1000)); /*Wait 1s to slow things down for testing purposes*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement