Tag Archives: tools

Arduino Variable Types Explained

Here’s something for reference.
I can never find just quite the succinct reference to Arduino Variable types. Nowhere could i find a list of minimum and maximum values, the bits, and the memory used by each variable type.

Neither was there any clear definition of meaning of ‘unsigned’, which just means no plus or minus signs in this type – that is all numbers positive. This increases the highest number that can be stored in the same memory. (thank me in the comments).

Usage Variable type Bits Min value Max value Ram usage Comments
common boolean 8 TRUE FALSE 1 byte
common byte 8 0 255 1 byte
char 8 -128 127 1 byte  A single ‘character’ e.g. ‘a’ is a single char.  Represented by chr(65) or the binary: 01000001
word 16 0 65535 2 byte
common int 16 -32768 32767 2 byte
unsigned long 32 0 4,294,967,295 4 byte
common long 32 -2,147,483,648 2,147,483,647 4 byte
common float 32 -3.4028235E+38 3.4028235E+38 4 byte
The below types are only included for compatibility or further study.
redundant unsigned char 8 0 255  1 byte use byte instead
redundant unsigned int 16 0 65535  2 bytes use word instead
redundant double 32 -3.4028235E+38  3.4028235E+38  4 bytes use float instead
The below types are special types (see arduino.cc)
special string variable  1 byte + x An array of chars
(used for storing strings to modify)
special enum variable  N/A Like boolean but custom fixed set of values allowed instead of TRUE/FALSE.
special struct variable  N/A Public sub variables
(as if you’d made a public class)
special pointer  N/A I’ll be honest, I wasn’t sure the use of this one. Here for completeness though!
Source: https://learn.sparkfun.com/tutorials/data-types-in-arduino
Source: https://playground.arduino.cc/Code/DatatypePractices
Remark: “Unsigned” means no negative sign. This increases the range of positive numbers available.
Remark: Unsigned variables that exceed their capacity roll over back to zero. This could be useful to iterate through arrays of limited length

PPS If anyone can figure out how to properly format this table so it looks nice, with ‘center’ aligned text, please let me know wordpress was being frustrating!

(The formatting css is in the source, see the table tag)

Link

Just a super-quick post here.

If you’re looking for addons or plugins for Microsoft Outlook to help you organize your emails and extend the functionality of Outlook

(note Outlook is very extensible, as with all Microsoft Office applications you can write Visual Basic code for Applications to hook into it’s functions. Absaloutely fantastic for hacking excel as I have been doing for the last few weeks – my work needs to invest in a proper database program for sure *sigh*)

You’d do no better than looking here

Snapfiles Outlook Add-ons

http://www.snapfiles.com/freeware/comm/fwoutlook.html

 

They have addons that are useful – and unlike most of the sites on i’ve found so far – up to date and compatible with recent versions (2003+) of Outlook.

Hope this helps folks!

 

USB Key reminder script

Here’s something for all you windows network admins out there.
(I apologize in advance to Johnathon’s linux followers)

Here’s a little script I wrote to be used as a group policy logoff script to remind users to remove their USB memory sticks/keys when logging off.

I wrote it while working in IT Support for a High School, to help out our IT teachers and ourselves as we were weekly gathering a collection of various USB Memory Sticks and memory keys (and since i was the one trying to reunite them with their owners each week.)

It’s written in VBS so it’s perfect for using as a group policy in active directory on say a Windows 2003 server/XP network. I haven’t tried it on Vista, Windows 7, or Server 2008 because I wasn’t using those technologies at the time, but it will most likely work with Vista and Windows 7 when deployed from a 2k3 or 2k8 server.

It detects removable drives (the type it looks for can be modified) that are connected and won’t pop-up without a drive detected.

If a USB drive is connected, it pops up a dialog reminding the user to take their memory stick with them and then auto-closes after a few seconds (as not to hang the logoff procedure).

I hope this is usefull to someone. If you use it, please leave me a comment.
[LICENCE GPL? NC-SA?]Also, feel free to modify and redistribute this script, but please don’t remove my details, as I’d like to know if it gets used and of any usefull additions others can think of.

[code]

‘ Script to display a list of drives connected to this machine
‘ http://authors.aspalliance.com/brettb/VBScriptDrivesCollection.asp
‘ MODIFIED to detect only removable drive. GTinsley 2008 @ Wallington County Grammar School.
‘  May cause false positives on some SATA ‘puters.
‘  Tested working on ‘puters with card readers.

Set FileSystemObject = CreateObject(“Scripting.FileSystemObject”) ‘Create a filesystem object
Set Drives = FileSystemObject.Drives ‘Create a drives collection

‘ Step through the drive collection, and get both the drive letter and the drive type.
‘ There are 6 distinct types of drive:
‘Select Case DriveType
‘   Case “0” DriveType = “Unknown type of drive”
‘   Case “1” DriveType = “Removable drive”
‘   Case “2” DriveType = “Fixed drive”
‘   Case “3” DriveType = “Network drive”
‘   Case “4” DriveType = “CD-ROM drive”
‘   Case “5” DriveType = “RAM Disk”
‘End Select

For Each DiskDrive in Drives

DriveLetter = DiskDrive.DriveLetter
DriveType = DiskDrive.DriveType

‘ Check for a removable drive connected that:
‘     Is not the drive letter A B or C
‘    Folder exists (proves the drive exists)
IF Drivetype = “1” and not driveletter = “C” and not driveletter = “A” and not driveletter = “B” and FileSystemObject.FolderExists(driveletter & “:\”) then

‘ Old method. Waits until user has clicked OK before logoff completes.
‘WScript.Echo “The removable disk drive ” & DriveLetter & ” is a still connected. Don’t forget your USB drive!”

‘ New method waits 5 seconds then logs off.

time_out = 5      ‘ wait max. 5 seconds
title = “Forgetting something?”
button = vbOKonly  ‘ vbOKOnly
message = “The Removable Disk (” & DriveLetter & “:\) is a still connected. Don’t forget your USB drive!”

Set objWSH = WScript.CreateObject(“Wscript.Shell”)     ‘ create object
objWSH.Popup message, time_out, title, buttons     ‘ popup
end if
Next

‘ Clear objects and collections
Set Drives = nothing
Set FileSystemObject = nothing

[/code]

Windows Command Line Ping Replacement

So the windows version of ping is really stupid.

I was writing a batch script to mount up a network share that involved checking to ensure my NAS unit was turned on. The script is scheduled to run after the computer resumes.

What I found out is that the built in version of Ping.exe is terrible at telling you whether the ping has returned successfully or not. I was checking the ERRORLEVEL – %ERRORLEVEL% variable to find out what ping was returning. It should be 0 for success and 1 or higher for a failure.

What I found was, i was getting replies from the local pc (dunno why, leave me a comment if you know) and ping was reporting a success even though the correct pc failed to reply. The solution?
Replace the Windows ping.exe with Fping. It has a lot more options and appears – from some initial quick tests – to correctly report the errorlevel.

Kudos to Wouter Dhondt for developing it. I’ll update this post with any more news!

 

image Fping vs Ping errorlevel return values

Quick useful sysadmin stuff

Two useful things I have found or use 🙂

Firefox Awesomebar search trick

A wonderful tip, that someone sent into the ubuntu-uk podcast. (I can’t remember who, or the episode. Comment if you know and I’ll credit them here! 🙂 )

You can search, in any website’s search function, using firefox’s address bar. Now, at first glance this sounds really boring and useless, but it really isn’t, at all.

First, we need to find a website to search. Let’s use launchpad’s bugs search, for Ubuntu. So, we go here:

https://bugs.launchpad.net/ubuntu/

Screenshot Firefox add search bookmarkThen, right click on the search box, and click “Add a keyword for this search”. This brings up the standard bookmark – your search keywords are stored as a bookmark. Give it a useful name, something to help you next time you go sorting through your book marks. Now, the keyword is how we use this trick. I’m going to use “bugs”, but you can use anything you want, just remember, this is the word you put before your search string in the address bar. Click Add.

Screenshot Firefox address bar search for bugsNow, all we have to do, is to search for a bug. Let’s use the classic bug 1.

Open a new tab (CTRL + T), then in the address bar type [your keyword] microsoft market share, and hit enter.

Lo and behold:

Screenshot Firefox launchpad bug 1

Testing SMTP-AUTH the fast way

Found a really handy little command line program called “swaks”. Great if you’ve ever needed to test SMTP-AUTH, and didn’t want to have to base64 the username and password yourself. Here’s a quick rundown on the command and flags I use with them. (Should be fairly obvious, comment if not!)

swaks -s [smtp-server-name-or-ip] -au [smtp-auth-user] -ap [smtp-auth-password] -f [from-address-of-testing-email]

Hit enter, and it’ll ask you the “to” email address. Type it in, and it gives you the full connection readout, just as if you were doing it with telnet (or netcat) on the command line:

<- 220 smtp.our-domain.com ESMTP
-> EHLO gemini
<- 250-smtp.our-domain.com
<- 250-AUTH LOGIN
<- 250-AUTH=LOGIN
<- 250-PIPELINING
<- 250 8BITMIME
-> AUTH LOGIN
<- 334 Z29vZCB0cnkgOikK

And so on. 🙂