Arduino Ethernet VNC Server

Here's tonight's very hacky project, a VNC Server running on an Arduino Ethernet board.

Here's the Arduino Ethernet VNC Server code and information.

Here's a screenshot of the sample output, it can also make your computer beep and write text to the clipboard:

Still need to work on the input side of things and make the code less cringe-worthy.

I was quite impressed with a few hours work and ~5KB compiled--including the original, larger, Ethernet library and some very inefficient code.

--Phil.

P.S. This does require one patch to the Ethernet library to enable detection of a client which has connected but not yet sent data. This is really a "missing feature" which should be implemented properly, rather than my quick fix. :-)

Wow! This is certainly a non-obvious use of the ethernet shield. I’ll definitely be watching for updates.

I’m trying to think of uses for this, and it seems like it should enable something important, but I’m still coming up empty. Do you have something specific in mind?

Okay, so the PC "logs in" to view what the Arduino has on its "screen." The Arduino definitely does not have enough RAM to actually have a regen video buffer. So the image has to be generated on the fly, whenever the PC's VNC client is requesting an update from the Arduino server's screen. Once the whole image has been generated, the Arduino could update smaller portions of the screen area, and the PC client would show those updates live.

I can see plenty of things this is useful for.

In fact, you might be able to stream the contents of one of those super-cheap video camera components on SparkFun. Or make a text/bitmap display that can summarize the status of a weather station. Or a microscopic command shell that lets you do live hardware I/O.

follower, VNC also supports sending keystrokes and mouse input from client to server. Have you played with that part of the loop yet? As for the "byte at a time" problem, I thought someone was already fixing that?

And which Ethernet shields/adapters are you using?

I'm trying to think of uses for this, and it seems like it should enable something important, but I'm still coming up empty. Do you have something specific in mind?

Heh, it's kinda like that, isn't it. :-) No, nothing specific in mind, just a case of "Hmmm, how hard would it be to..." and "Hmmm, wouldn't it be cool if...". :D

Essentially it provides an additional option for a network interface instead of HTML or Adobe Flash, I have no idea if it's a useful option. :-)

--Phil.

In fact, you might be able to stream the contents of one of those super-cheap video camera components on SparkFun.

I wondered about doing something like that with the serial camera folks seem to have had success with lately--although it isn't cheap.

Or make a text/bitmap display that can summarize the status of a weather station.

Yeah, I wonder about using it for accessing multiple remote sensor displays but I'm not sure if it offers a real advantage over HTML.

Or a microscopic command shell that lets you do live hardware I/O.

Or a point-and-click style interface.

follower, VNC also supports sending keystrokes and mouse input from client to server. Have you played with that part of the loop yet?

I haven't played with that yet but intend to, that's what I was referring to by my "input side of things" comment. :-)

As for the "byte at a time" problem, I thought someone was already fixing that?

Yeah, me. :-) I just hadn't transferred the code over--plus this code needs to have null bytes, plus it needs to avoid buffering which still hasn't really got a solution yet.

And which Ethernet shields/adapters are you using?

I'm using the unreleased Arduino Ethernet board prototype but it uses the standard Ethernet library so it should work with the official WIZnet Arduino Ethernet shields and compatibles.

--Phil.

Now that's cool. Since you're (somewhat?) divorced from timing issues, can you use this sort of thing to implement the "high resolution video display" that people keep asking for? (rendering high-level graphics objects and text "on the fly" as it were?)

plus this code needs to have null bytes, plus it needs to avoid buffering which still hasn't really got a solution yet

Null bytes? You mean packets containing 0x00, or you mean packets of length zero? I didn't realize the Ethernet library disallowed the former, and didn't realize TCP allowed the latter. :)

As for buffering, sounds like you need a Nagle's Algorithm switch. If enabled, allow output buffering but a timer will send the current buffer if you don't explicitly flush() to send what you've built up.

Since you're (somewhat?) divorced from timing issues, can you use this sort of thing to implement the "high resolution video display" that people keep asking for? (rendering high-level graphics objects and text "on the fly" as it were?)

I'm not 100% sure I understand your question.

You could--at least in theory--create a high-resolution (but probably low refresh speed) screen but that would still need to be displayed on a full (or thin client) system with a standard monitor. So, I'm not sure if it would really provide what people want--given you could just transfer the data used to create the display and display it locally on the PC.

I haven't managed to envision a scenario in which it would make more sense to generate the display on the Arduino rather than just transmitting the raw data and creating the display on the viewer PC--unless it's to eliminate the need for installing specific software other than a VNC viewer on the machine.

--Phil.

Null bytes? You mean packets containing 0x00, or you mean packets of length zero? I didn't realize the Ethernet library disallowed the former, and didn't realize TCP allowed the latter. :)

I mean packet data containing 0x00. Unless you use the byte-at-time write method you can't send an array of bytes that contain 0x00 due to the current print-style handling of null bytes as string terminators.

As for buffering, sounds like you need a Nagle's Algorithm switch. If enabled, allow output buffering but a timer will send the current buffer if you don't explicitly flush() to send what you've built up.

Yeah, there's been some discussion on the Developer list that has included references to Nagle, although I think at a lower level than the example you give.

Not sure if using a timer is justified by the benefit or not...

--Phil.