Hi EvilSOB!
Thanks for this library. We've been using it for a couple of days to try and communicate with a Micro Controller.

We got the communication to work now, except for one problem:
If the connection is not constantly busy (constantly meaning sending stuff about once a second from MC to the COM port, it seems to "time out"). We're using a USB-Adapter, and here is the code:

Code:
void collectInput(var hPort)
{
	(inputText.pstring)[0] = inputStr;
	inputText.pos_y = screen_size.y - 25;
	while(1)
	{
		result = inkey(inputStr);
		//		while(inkey_active == ON) wait(1);
		if(result == 13)
		{
			port_write_bytes(hPort,_chr(inputStr), str_len(inputStr)+1,1);
			appendLine(sendTxt, inputStr);
		}
		str_cpy(inputStr, "               ");
		wait(1);
	}
}


byte singleByte = -1;
byte inputBytes[10] = {0,0,0,0,0,0,0,0,0,0};
double inputDouble = -1;
var resetCharArray()
{
	var count = 0;
	while(count < 10)
	{
		inputBytes[count] = 0;
		count += 1;
	}
}


void receiveData(var hPort)
{
	STRING* inputStr = str_create("");
	var count = 0;
	while(1)
	{
		if(key_esc)	break;
		
		result = port_read_bytes(hPort,singleByte,1);
		
		if(result > 0)
		{
			if(singleByte == 0 || count == 9)
			{
				count = 0;
				appendLine(receiveTxt, _str(inputBytes));
				resetCharArray();
			}
			else
			{
				inputBytes[count] = singleByte;
				count += 1;
			}
		}		
		wait(1);
	}
}


function main()
{
	wait(1);
	appendLine(sendTxt, "Started.");
	
	
	on_close = exit_safely;
	initLevel();
	on_esc = NULL;
	byte last_recieved = 0;
	hPort = port_open_readwrite("COM2", "9600,n,8,1");
	if(hPort)
	{
		collectInput(hPort);
		receiveData(hPort);
		wait_for(receiveData);
		port_close(hPort);
	}
	else
	{
		error("Error connecting to Port");
		while(key_esc == OFF) wait(1);
	}
	sys_exit("");	
}



We can't figure this one out.
If we don't send a "NULL" from the MC to the PC every second, then nothing seems to be received any more at all.


~"I never let school interfere with my education"~
-Mark Twain