OpenAccess Serial commands

The serial command library I use for this is specially modified to take advantage of the more ram the 2560 has by pre-allocating memory for my big commands.

//library to allow it to take commands from serial
#include <SerialCommand2560.h>
SerialCommand2560 SCmd; // The demo SerialCommand object

The commands are defined in the setup like this:

// Setup callbacks for SerialCommand commands
SCmd.addCommand(“ON”,SCmd_relay_on); // Turns relay on
//format: ON;<relay number(not pin number)>
SCmd.addCommand(“OFF”,SCmd_relay_off); // Turns relay off
//format: OFF;<relay number(not pin number)>
SCmd.addCommand(“TOGGLE”,SCmd_toggle); // Toggles relay with duration
//format: TOGGLE;<relay number(not pin number)>;<time to be on for in a ‘delay(arg)’ format>
SCmd.addCommand(“RTC”,SCmd_rtc); // uses RTC
//format: RTC;<0=write, 1=read>;<second, 0-59 (write only)>;<minute,0-59 (write only)>;<hour, 1-23 (write only)>;<dayOfWeek, 1-7 (write only)>;<dayOfMonth, 1-28/29/30/31 (write only)>;<month, 1-12 (write only)>;<year, 0-99 (write only)>
SCmd.addCommand(“DISP”,SCmd_display); // uses display
//format: DISP;<0=line 1, 1=line 2 (or no argument to clear the display)>;<string (or no argument to clear the line)>
SCmd.addCommand(“PRINT”,SCmd_print); // uses printer
//format: PRINT;<string>
SCmd.addCommand(“CONTRAST”,SCmd_contrast); // sets contrast
//format: CONTRAST;<analog value, 0-255 or nothing for default>
SCmd.addCommand(“BACKLIGHT”,SCmd_backlight); // sets backlight
//format: BACKLIGHT;<analog value, 0-255 or nothing for default>
SCmd.addCommand(“BAT”,check_battery); // reads battery voltage
//format: BAT
SCmd.addCommand(“TEMP”,check_temp); // reads temperature
//format: TEMP
SCmd.addCommand(“BEEP”,SCmd_beep); // beeps reader<reader number> for <duration> in delay(arg) format
//format: BEEP;<reader number>,<duration>
SCmd.addCommand(“READ_CMD”,SCmd_read_CMD); // dumps the command area of the EEPROM
//format: READ_CMD
SCmd.addCommand(“DUMP_USR”,SCmd_dump_users); // dumps all users up to index
//format: DUMP_USR
SCmd.addCommand(“ADD_USR”,SCmd_add_user); // adds a user at a given index
//format: ADD_USR;<index>;<name>;<priv byte>;<hash>
SCmd.addCommand(“READ_USR”,SCmd_read_user); // reads the user at <index>
//format: READ_USR;<index>
SCmd.addCommand(“RMV_USR”,SCmd_remove_user); // removes the user at <index>
//format: RMV_USR;<index>
SCmd.addCommand(“RMV_USRN”,SCmd_remove_user_name); // removes the user with <name>
//format: RMV_USRN;<name>
SCmd.addCommand(“RMV_USRH”,SCmd_remove_user_hash); // removes the user with <hash>
//format: RMV_USRH;<hash>
SCmd.addDefaultHandler(unrecognized); // Handler for command that isn’t matched (says “What?”)

I am rather proud of how well documented these are, so I will leave this as a reference page.  In the main loop this is all that’s needed to check for these commands:

SCmd.readSerial(); //process serial commands

There’s your reference of my serial commands for the OpenAccess project.

Advertisements

One Response to “OpenAccess Serial commands”

  1. OpenAccess 3.0 replacement software | Evan's Techie-Blog Says:

    […] Serial commands […]

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


%d bloggers like this: