hier ist der Code zur Initialisierung der Schnittstellen und der Motoren,
könntet ihr ein paar Verbesserungstipps geben?

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>      //for isdigit()
#include <math.h>       //for sin(), cos()
#include <process.h>	//for multithread
#include <windows.h>    //for PCOMM.h and multimedia timer
#include "../Moxa/PComm.h"      //Serial Communication Libarary
#include "../Moxa/MoxaFunction.h"
#include "GlobalFunction.h"

void init (int port)
{
	/* Port Control, enable the port */
	if (sio_open(port) == SIO_OK)
	{
		sio_ioctl(port, B38400, P_NONE | BIT_8 | STOP_1 );
		// Port Control, set baud, parity...
		sio_flowctrl ( port, 0xc );			//0XC: software flow control: XON/XOFF
		sio_DTR (port, 0 ); //turn DTR off
		sio_RTS (port, 0 ); //turn RTS off
		sio_flush (port, 2);
		/*	
		0 : flush input buffer
		1 : flush output buffer
		2 : flush input & output buffer
		*/
		sio_SetReadTimeouts(port, 0, 0);
		// Set sio_read into block mode, which is used in readposition()
		sio_SetWriteTimeouts(port,0);
		//Set sio_write into block mode
	}
	else 
	{
		printf("Cannot Open Port%d !!!\n", port);
		system("pause");
		exit(-1);
	}

                // tp: tell position -> definierte Funktion
	if (tp(port) != 0)
	{
		pq(port);// pq: Power Quit
	}

	if (port == MotorOne)
	{
		printf("Motor One Status:\t");
	}

	if (port == MotorTwo)
	{
		printf("Motor Two Status:\t");
	}		
		
	if (port == MotorThree) 
	{
		printf("Motor Three Status:\t");
	}

	pw(port);
	printf("Power ON\t\t\n\n");
	//printf("%9d\n\n",tp(port));
}