Learning About Arduino and VNC
Introduction
Implementation of a VNC server on an Arduino Ethernet board.
Code
- First cut, should display a blank window: VNCServer_001.pde
- Version 002, bell, clipboard, one colourful frame: VNCServer_002.pde
- Version 003 tidied from above, but with a cycle of colours: VNCServer_003.pde (delayed upload, not recently tested)
Links
- Protocol specification: rfbproto.pdf
- rfbcounter -- "A really simple VNC server." Example of a non-desktop interface in the form of a counter (link above shows screen shot of a CD player application)-- try this link to rfbcounter.tar.gz
Project Log
( 28 March 2009 )
- Have only just realised that both Arduino and Processing define the Server.available method as meaning "Gets a client that is connected to the server and has data available for reading ." So there's no way to retrieve a client that has connected but not yet sent any data—which means all data transfer has to be initiated by the client. Which is a problem with a protocol like VNC where the server is expected to respond to the connection with data.
- Added a cut & paste hack job to enable retrieval of a client that has connected but not yet sent data. @@ TODO: Submit bug report & proper patch.
- Add to Server.cpp :
#if 1
Client Server::connected()
{
accept();
for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
Client client(sock);
if (EthernetClass::_server_port[sock] ==_port &&
client.status() == SOCK_ESTABLISHED) {
// XXX: don't always pick the lowest numbered socket.
return client;
}
}
return Client(255);
}
#endif
- Add to Server.h :
#if 1 Client connected(); #endif
- Successfully connected with "Chicken of the VNC" client to display 0/port 5900:
Mar 28 03:12:23 XXXXX Chicken of the VNC[24645]: Server reports Version RFB 003.003
- Successfully displayed a blank window, uploaded code:

- Successfully sent back a "bell" instruction so the computer beeps, sent back clipboard content "Hello" and updated the display:
- The screen update is painfully slow as it's all going one byte at a time, with the associated packet overhead. Definite progress though.
- Resisting the temptation to implement input handling too, will aim for sleep instead.
- Uploaded latest version of hacky code, compiled size 5360 bytes.