The Simple Serial Terminal revisited

My prototype ESP-03 board“Got up early one morning….”  well, actually it was one evening a couple of week ago, I was frantically struggling to use the Arduino serial monitor to test the new ESP-01 modules (which appear to have had babies, they’re all over the place now) and not getting very far, one line at a time, repeating the same typing mistakes over and over…  and I decided I needed something better. Windows programming is not something I’ve done for a while (as against web and App programming). The last time I wrote anything major was back in the dark ages of VB6 and so I was expecting to fail completely with Visual Studio though I use it a lot for embedded C programming, desktop apps are another matter.  I managed to find some code to take data from the serial port, put it up on screen and vice-versa and the funny thing is it all started coming back to me. The project that was going to take me the drinking time of a cup of coffee took all night and I was so happy with it I stuck a copy on the web. I have to say version 0.1 looked pretty naff.

Scargill's Serial TerminalBack to programming the pesky ESP8266 chips and once again I found myself getting more and more frustrated. I needed places to store things temporarily, I got annoyed when as happened one night, the power went off mid-stream and I lost all my temporary notes and… well, if you’ve worked on these chips, having to discover the bugs as you go along and repeating the same stuff with minor variations until you got there, you’ll know exactly how I feel. On top of that, the interpreter hates you sending stuff quickly and whenever I looked it up on the web I kept getting recommended to use some Linux program or other – sorry guys.. NO.

Fast forward to this morning where I realised just what an amazing little tool I’d put together with a few late nights behind me (and I mean LATE). Now, before I say any more, apologies to anyone on Windows XP – I can’t help here because the Microsoft environment really isn’t supporting XP any more – it’s not me, the code  just won’t work on XP. As for the Linux guys, well, you’ve probably got your own tools and they’ll be far better so I’m not worried about you so this is for Windows 7 and upwards.

So specific needs when messing with these chips – and especially when using the Lua interpreter – you need to be able to send blocks of code to the chip over and over as your program evolves and you need to be able to store temporary solutions, lots of them. The Lua interpreter has a strange file system that means when creating a file you need to wrap your code in the most horrible mess which makes it almost unreadable – just what you don’t need when bugs creep in. You need delays between each line you send, maybe up to half a second as the interpreter does not like being sent serial data when it’s busy. You also need to be able to blow firmware onto the boards but I haven’t gotten that far yet and anyway there are some decent Windows tools out there to do just that.

And so here we are two weeks later – I have the tool I need to do the job and I realise I’ve done a pretty awful job of documentation. So above right you should see the editor. The most important bits are the two big windows – on the left is the area you type in – multi line – and on the right is the output from the serial line – i.e. what comes back from the chip. In the simplest case you set up the serial port you want, ensure it’s set to 9600 baud, select “serial – open” and you’re all set (I’m assuming you have an FTDI or similar on your USB lead, talking to the serial on the ESP8266 device, I’m also assuming you fed 3v3 to the device and are using some means of ensuring the device never gets hit with anything above 3v3).

Whatever you type in the left window is non-volatile, i.e. it’ll still be there after you blow up your serial port and have to reboot the computer.

Disclaimer: if any of the above or the use of the terminal breaks your computer, it’s not my fault. I’m providing this freely just because I’ve no reason not to but without support.

The top panel

So let’s take a look at the top first. I have deliberately kept this as clean and simple looking as possible as you really just want to get on with coding and not worry about some pesky program – but there are some basics if you want to make good use of this. The file system is easy enough – you might want to store what’s in your left window – your latest all-singing routine or just a bunch of nonsense – that’s up to you hence file – save. Find a suitable directory to store your stuff – the dialog is bog-standard. For retrieval – you have two options, load and append. The former will overwrite what’s in the window, the latter will append to what’s there – so you can store a load of routines and build up something new the easy way.

NotepadSerial is even simpler – open or close the port. When open you’ll find some controls don’t work – like changing the baud rate for example.

Notepad is interesting…yes, no less than 10 pretty coloured notepads (non-volatile) to store snippets in – nothing clever about these, you can just copy and paste to and from them in the normal way.

I normally have several projects going on and find it handy to have stuff lying around – this beats yellow sticky notes full of code any day. There’s a big HIDE button at the bottom to get rid of these – and don’t be fooled by access to the ribbon when Notepad is open – it’s disabled.

NotepadClear- well you can clear the notepads or your left or right windows – and help – well it’s a picture of me – the idea of writing a complete help system for this just filled me with horror.

So down at the BOTTOM of the screen… assuming you have the serial all turned on you can “Send Window” – i.e. send the contents of your left window off to the serial port – it will send it one line at a time with a delay between each line specified at the top right in milliseconds, defaulting to 400ms – but whatever works for you. 

I’ve coloured the individual panels just to try to help for when you’re in a hurry – I tried to colour the tabs but Microsoft isn’t having any of it up to now.

If you select some text in the normal way in that left panel you can press the “Send Selected” button and only send the stuff that is highlighted – OR you can “copy” from just about anywhere and send whatever is in your clipboard… that’s awfully handy. 

The bottom panelThen there are those notes.. N1 to 10 let you send the entire contents of any of those notepads.  Finally there is a one-line window which you can send directly with the “Direct” button and that has autocomplete for some of the more useful commands.

To the right there are some presets, 6 in all – and in SETTINGS you can define their names and what gets sent out.  And that takes us to settings.

Settings

Firstly you’ll see the 6 preset buttons – their titles and contents – note you DO have to press OK to save these – most things outside of this SETTINGS box just save automatically. Auto prefix and suffix I suggest you leave be unless you’re NOT messing with Lua and the “Auto prefix/Suffix” tickbox determines whether or not you use this – essentially if “File.open” is see starting at the LEFTMOST character in your input window, these prefix/suffix characters will be added to your line as they are being sent out until the system sees a “File.close” again starting in the leftmost column of your input window.

“Arduino DTR” – well that’s for those of you who want to use this terminal with your Arduinos (you may be working with the Espressif AT firmware for example)  – that’s the bit that resets them when you open the port. It just flicks the DTR line temporarily on open – nothing more. Autoclear – tick that and you’ll see the right window cleared every time you press the send button – just preference really. Lua comment removal is turned on by default (—) – you can turned if off – and “Retain blank lines” is new, just something for the future. Normally, most blank lines never make it to the right window.

And that is that, really – nothing much else to tell you about the program – I hope you find it useful – I have – and no doubt I’ll add more in time.

Oh apologies to the guys who now find the Lua interpreter returns NIL when empty… I think that was my idea. I keep firing stuff off to Zeroday who is doing a cracking job on what can’t be a trivial project.

Oh here’s the dropbox link – not sure how long this will stay valid but you can always let me know if it disappears.

Note: If you’re interested in what I’m doing here… join my millions of followers on the ESP8266 Facebook page (actually it was 41 at last count) https://www.facebook.com/esp8266wifi or check me out on Google+ https://plus.google.com/+PeterScargill  if Twitter is your thing… https://twitter.com/scargill erm, what else.. oh yes www.scargill.net or www.bedrock.es or www.hollyberry-cottage.co.uk … I think that’s about it.

Advertisements

6 thoughts on “The Simple Serial Terminal revisited

  1. Oh, something I forgot to mention. In visual studio, your can right click on your project in solution explorer, select properties, then the Application tab, here you can change the .net target framework to target .net 4 rather than 4.5 and it should create a build suitable for XP.

    It should work providing you’ve not used any .net 4.5 specific features. I don’t develop using visual basic, (I’m a c# programmer), but this should work to get XP working.

    Glen.

  2. Great work on documenting these cool new chips.

    I am attempting to see if I can use one of these as a drop-in replacement for the nrf24. I am running “Project Oberon” on an FPGA which uses the NRF24 chip as it’s network interface card. Are they easily interchangeable?

    Oberon will boogle your mind. Even better, take a look at PICL, an Oberon compiler for 8 bit AVR’s. Now, imagine an Oberon compiler for the Tensilica target. All these programming woes would be gone. LUA? Really? I will bet the same Oberon code will be 10 times smaller. The Arduino .bin file for “Blinker.ino” is 12 times larger than the “BlinkerDemo” executable produced by Oberon (Astrobe Oberon for ARM). Of coarse, that is a distant goal, but not nearly as far as one would imagine.

    http://www.inf.ethz.ch/personal/wirth/PICL/index.html

    projectoberon.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s