another ofSerial extension

i needed a way to close an open serial port.
i only have pcs to work on at the moment, so i only implemented it for winXP.
it should be simple to add a mac os version.

here’s my code:

  
  
bool ofSerialClose ()  
{  
	if (!bInited){  
		printf("error: serial not inited\n");  
		return 0;  
	}  
	bInited = false;  
	//---------------------------------------------  
	#ifdef TARGET_OSX  
	//---------------------------------------------  
  
    // add mac os x code here...  
  
	//---------------------------------------------  
	#endif  
	//---------------------------------------------  
  
	//---------------------------------------------  
   	#ifdef TARGET_WIN32  
	//---------------------------------------------  
	return CloseHandle(hComm);  
	//---------------------------------------------  
	#endif  
	//---------------------------------------------  
}  
  

hi thanks!

that’s a very helpful point about serial -

we invite you to check out the new (but not thoroughly tested) serial class with a bunch of the modifications people have been asking for:

http://www.openframeworks.cc/admin/inde-…-munication

it’s object oriented. we will add your code to it, since it makes sense to be able to close the serial class as well as open it :oops:

thanks again!!
zach