Hey all
---------------------------------------------------------------------------------------
Introduction
---------------------------------------------------------------------------------------
I haven't made any new plugins recently, but I received my Arduino Uno board about a week ago, and since I also bought an MPU-6050 motion sensor on a GY-521 breakout board (for all of $5 on eBay), I wanted to get my Arduino communicating with DBPro so I could easily display a 3D object that rotated according to the angle of the physical chip. This resulted in quite a bit of Googling because I knew virtually nothing about serial communication, but the end result is Simple Serial. It's basically a wrapper for the surprisingly minimalistic code from
here, so I can't and don't claim credit for most of the actual serial code, but I did make a few modifications for extra functions and flexibility
The plugin is designed primarily for easy communication with Arduinos, so there's a few default values that are best suited to that purpose, however everything can be changed to communicated with most any serial device. As far as I know it doesn't support opening more than one channel of communication at a time, and believe if you try you'll either get errors or end up with memory leaks
Full source code is included. To compile, you'll have to add
C:\Program Files (x86)\Microsoft DirectX SDK (August 2007)\Include as an additional include directory (which obviously means you need to have downloaded and installed the August 2007 version of the DX SDK). You'll also have to add the directories containing the standard DBPro files (like globstruct.h, DBOData.h and global.h), all of which can be found in the Extras folder in your DBPro install directory. Additionally, you will need to add the
C:\Program Files (x86)\Microsoft DirectX SDK (August 2007)\Lib\x86 folder to the additional library directories. You'll need Visual Studio C++ 2008 to compile.
If you just want to use the DLL, extract the Compiler and Editor folders straight into your DBPro install directory and restart DBPro
A readme is included as simple documentation, but I'll repeat the instructions here.
---------------------------------------------------------------------------------------
List of commands
---------------------------------------------------------------------------------------
SERIAL SET ARDUINO WAIT TIME==WaitTime
Not sure how useful this is, but it's here nonetheless. All it does is set (in milliseconds) how long the SERIAL OPEN command should wait before returning, to give the Arduino time to restart. Just set this to 0 if you don't want a 2-second pause when you call SERIAL OPEN

Defaults:
WaitTime: 2000
SERIAL OPEN==[Port$][Port$, BaudRate][Port$, BaudRate, ByteSize, StopBits, Parity]
Call like this:
serial open "COM3" Defaults:
BaudRate: 9600
ByteSize: 8
StopBits: 0
Parity: 0
Valid options are (for more specific data, look in WinBase.h, which is a standard Windows include file AFAIK):
BaudRate:
#define CBR_110 110
#define CBR_300 300
#define CBR_600 600
#define CBR_1200 1200
#define CBR_2400 2400
#define CBR_4800 4800
#define CBR_9600 9600
#define CBR_14400 14400
#define CBR_19200 19200
#define CBR_38400 38400
#define CBR_56000 56000
#define CBR_57600 57600
#define CBR_115200 115200
#define CBR_128000 128000
#define CBR_256000 256000
ByteSize: Anything, presumably.
StopBits:
#define ONESTOPBIT 0
#define ONE5STOPBITS 1
#define TWOSTOPBITS 2
Parity:
#define NOPARITY 0
#define ODDPARITY 1
#define EVENPARITY 2
#define MARKPARITY 3
#define SPACEPARITY 4
SERIAL CLOSE==*no parameters*
Should make it safe to call SERIAL OPEN again. Untested.
SERIAL IS CONNECTED==(*no parameters*)
Use this to detect if the attempted connection was successful.
SERIAL DATA AVAILABLE==(*no parameters*)
Returns how many bytes (if any) are sitting in the buffer, waiting to be read. If none, returns 0.
SERIAL READ STRING==(Bytes)
Reads an array of bytes in the form of a string. Good for getting lots of data at once. Will attempt to retrieve the number of bytes set with the parameter Bytes. If there are not enough available, will return as many as possible.
SERIAL READ BYTE==(*no parameters*)
Reads just one byte at a time.
SERIAL WRITE STRING==(Data, Bytes)
Sends a string as an array of bytes. Set Bytes to the number of characters in the string. Possibly also needs to be length+1 for null-terminated strings. Returns number of bytes successfully sent.
SERIAL WRITE BYTE==(Data)
Sends a single byte. Also returns number of bytes successfully sent, but since there's only one byte, will only return 0 (unsuccessful) or 1 (successful).
SERIAL GET LAST ERROR==(*no parameters*)
Returns a number referring to one of the following error values (again, from WinBase.h):
#define CE_RXOVER 0x0001 // Receive Queue overflow
#define CE_OVERRUN 0x0002 // Receive Overrun Error
#define CE_RXPARITY 0x0004 // Receive Parity Error
#define CE_FRAME 0x0008 // Receive Framing error
#define CE_BREAK 0x0010 // Break Detected
#define CE_TXFULL 0x0100 // TX Queue is full
#define CE_PTO 0x0200 // LPTx Timeout
#define CE_IOE 0x0400 // LPTx I/O Error
#define CE_DNS 0x0800 // LPTx Device not selected
#define CE_OOP 0x1000 // LPTx Out-Of-Paper
#define CE_MODE 0x8000 // Requested mode unsupported
---------------------------------------------------------------------------------------
Example usage
---------------------------------------------------------------------------------------
serial open "COM3",115200
if serial is connected()=0
exit prompt "failed to open port",""
end
endif
do
if serial data available()>0
result=serial read byte()
endif
loop
---------------------------------------------------------------------------------------
Download
---------------------------------------------------------------------------------------
2015/01/02 - V1.0 - Current
That's all for now. If you need any help with this or find a bug, don't hesitate to reply here