This package contains a simple test of tests for various elements of the SmartBoard hardware, which is a simple baseboard designed for easy embedding. It is able to run both a semi-automatic test suite as well as allow interactive testing.

Dependencies:   EthernetNetIf NTPClient_NetServices mbed

Embed: (wiki syntax)

« Back to documentation index

SmartBoard_Tester.cpp File Reference

SmartBoard_Tester.cpp File Reference

is the simple test framework More...

Go to the source code of this file.

Functions

void LED_Tests (void)
 !< time zone offset minutes to print time in local time
void PWM_Tests (void)
 PWM_Tests performs some simple pwm output to the PWM channels and the LEDs.
void AnalogIn_Tests (void)
 AnalogIn_Tests takes a few sample measurements on each channel.
void RTC_Tests (void)
 RTC_Tests will perform simple tests on the Real Time Clock.
void RTC_Set (void)
 RTC_Set will interactively set the Real Time Clock.
void MicroSD_Tests (void)
 MicroSD_Tests attempts to access and write a file on the micro SD card.
void RS_232_Tests (void)
 RS_232_Tests will say hello on each of the RS-232 channels.
void CAN_Tests (void)
 CAN_Tests will send some packets on one CAN port and expect them on the other.
void Ethernet_Tests (void)
 Ethernet_Tests will attempt to test the Ethernet interface.
void USBHost_Tests (void)
 USBHost_Tests attempts to access and write a file on USB stick.
void FileSystem_Tests (void)
 FileSystem_Tests attempts to access and write a file on the local file system.
bool TestVector (int i)
 TestVector will execute a given test, based on the parameter.
int main ()
 main is the main startup code.
int GetNumber (int digits, int *pValue)
 GetNumber will get from the user a number using the specified number of digits.
bool isPrint (char i)
 isPrint tests the passed in character for being 'printable'
void RunFileSystemTest (const char *folder, const char *file, const char *textMessage, int COUNTLIMIT)
 common file system test to write and then read a moderately large file
char * FormatMicroseconds (int value)
 FormatMicroseconds will format a number of microseconds int ascii seconds.
void ShowCANMessage (int tx, int ch, CANMessage msg, int uSec)
 ShowCANMessage will print to the console as specified.

Variables

const char * TicTocServer = "ntp.okstate.edu"
 !< Used as the console for interactively reporting progress
const int tzOffsetHr = -6
 !< time server since it is closer than "0.uk.pool.ntp.org"
const int tzOffsetMin = 0
 !< time zone offset hours to print time in local time

Detailed Description

is the simple test framework

This file contains the startup, interactive, and test code to evaluate the SmartBoard baseboard.

Note:
Copyright © 2011 by Smartware Computing, all rights reserved. This software may be used to derive new software, as long as this copyright statement remains in the source file.
Author:
David Smart

Definition in file SmartBoard_Tester.cpp.


Function Documentation

void AnalogIn_Tests ( void   )

AnalogIn_Tests takes a few sample measurements on each channel.

It samples each channel a number of times and presents the converted results on the console.

Definition at line 283 of file SmartBoard_Tester.cpp.

void CAN_Tests ( void   )

CAN_Tests will send some packets on one CAN port and expect them on the other.

It will attempt to send 10 messages on one port and expect that all 10 messages were received on the other port. The two ports should be wired from one to the other with a loop-back cable and a termination resistor.

Definition at line 676 of file SmartBoard_Tester.cpp.

void Ethernet_Tests ( void   )

Ethernet_Tests will attempt to test the Ethernet interface.

It will connect to the network - if possible, then it will try to connect to a network time server and set the clock, using hard coded time server and time zone offset values.

It appears that the Ethernet interface cannot be instantiated, destroyed, and later instantiated again (it would reliably "hang"). So, this test is "runonce" protected.

Definition at line 444 of file SmartBoard_Tester.cpp.

void FileSystem_Tests ( void   )

FileSystem_Tests attempts to access and write a file on the local file system.

It will mount the file system, then attempt to write a simple file on the interface. While file handles are open, the USB drive will be unavailable.

Definition at line 598 of file SmartBoard_Tester.cpp.

char* FormatMicroseconds ( int  value )

FormatMicroseconds will format a number of microseconds int ascii seconds.

It will support formatting the number with decimal and thousands separators.

Parameters:
valueto format
Returns:
the formatted string "0034.123456"

Definition at line 620 of file SmartBoard_Tester.cpp.

int GetNumber ( int  digits,
int *  pValue 
)

GetNumber will get from the user a number using the specified number of digits.

They can enter a number from 0 to 10^(digits-1)

Parameters:
digitsis the number of digits to enter
pValueis a pointer to where to store the result
Returns:
true if a number was entered
false if they entered a non-digit

Definition at line 354 of file SmartBoard_Tester.cpp.

bool isPrint ( char  i )

isPrint tests the passed in character for being 'printable'

It will evaluate the character on a simple ASCII range of characters 0 to 127.

Parameters:
iis the character to test
Returns:
true if the character is in the printable set (including <space>)
false if the character is not printable (may be control code or extended character)

Definition at line 479 of file SmartBoard_Tester.cpp.

void LED_Tests ( void   )

!< time zone offset minutes to print time in local time

LED_Tests performs some simple digital output to the LEDs.

It will attempt to exercise the LEDs on the Ethernet ports as well, but by jumper configuration these may not be available.

Definition at line 208 of file SmartBoard_Tester.cpp.

int main (  )

main is the main startup code.

This initializes the test environment, shows a banner, and starts the automated testing. It also detects if the user is attempting to interact, and between each test category there is the possibility to transfer to the interactive test mode. When in interactive test mode, the user determines which test to run. The user can also exit interactive mode back to the automated test mode.

Returns:
never

!< init is slightly different

!< track when in interactive mode

!< which test to run

!< list of valid test commands AUTOTESTS are uppercase

Definition at line 131 of file SmartBoard_Tester.cpp.

void MicroSD_Tests ( void   )

MicroSD_Tests attempts to access and write a file on the micro SD card.

It will mount the file system, then attempt to write a simple file on the micro SD card.

Definition at line 558 of file SmartBoard_Tester.cpp.

void PWM_Tests ( void   )

PWM_Tests performs some simple pwm output to the PWM channels and the LEDs.

It will attempt to exercise the outputs with a simple ramping signal, but by jumper configuration these may not be available.

Definition at line 243 of file SmartBoard_Tester.cpp.

void RS_232_Tests ( void   )

RS_232_Tests will say hello on each of the RS-232 channels.

It will print a hello text string out each of the ports.

Definition at line 725 of file SmartBoard_Tester.cpp.

void RTC_Set ( void   )

RTC_Set will interactively set the Real Time Clock.

It will allow you to enter the date and time information and then create a timestamp. After this, it will set the RTC to that timestamp.

Definition at line 379 of file SmartBoard_Tester.cpp.

void RTC_Tests ( void   )

RTC_Tests will perform simple tests on the Real Time Clock.

It will first sample the time from the RTC and later restore it as best it can. In the middle of that it will set the clock, then simply show the time once per second for 5 seconds. After this it will restore the clock at best it can.

Definition at line 321 of file SmartBoard_Tester.cpp.

void RunFileSystemTest ( const char *  folder,
const char *  file,
const char *  textMessage,
int  COUNTLIMIT 
)

common file system test to write and then read a moderately large file

This will create a folder and then open a file for write. It will write a text string to the file and defined number of times and close the file. It will then report the performance metrics in bytes/sec write. It will then open the same file for read and read the file back, one record at a time. It will then report the performance metrics for the read in bytes/sec.

Parameters:
folderis the folder name to create
fileis the filename to create
textMessageis the text message to use in the test
COUNTLIMITis the number of times the text is written to the file
Returns:
nothing

Definition at line 500 of file SmartBoard_Tester.cpp.

void ShowCANMessage ( int  tx,
int  ch,
CANMessage  msg,
int  uSec 
)

ShowCANMessage will print to the console as specified.

This format is used in other tools, and is not explained here beyond what you see

+--- 'r'eceive or 't'ransmit | +--- 'nrm' 11 bit identifier, 'xtd' 29 bit identifier | | +--- channel '1' to '2' | | | +--- identifier in hex | | | | +-- dlc - data length control | | | | | +--------------------+ data bytes 1 to 8 | | | | | | +--- fixed zero for compatibility with other tools | | | | | | | +-- fixed zero for compat | | | | | | | | +--- timestamp | | | | | | | | | _ ___ _ ________ __ _______________________ _ ___ ___________ r xtd 2 1CF00400 08 11 22 33 44 55 66 77 88 0 0 1234.567890 t xtd 1 18EAFF03 03 EE EE 00 0 0 1235.654321

Parameters:
txindicates it is a transmit message when non-zero, receive otherwise
chis the communication channel of this message is the CAN message to be shown is the timestamp in microseconds
Returns:
nothing

Definition at line 655 of file SmartBoard_Tester.cpp.

bool TestVector ( int  i )

TestVector will execute a given test, based on the parameter.

It can show the list of available commands, as for an interactive test session, or it can simply execute the chosen test. This is used for both the automated testing and the interactive testing, so a couple of the commands for interactive would not be used for the automated testing. '?' causes it to display the available commands.

Parameters:
icontains the single character value indicating the operation to perform.
Returns:
false if the input paramter was 'X'.
true if the input parameters was not 'X'.

!< expect to return true

Definition at line 59 of file SmartBoard_Tester.cpp.

void USBHost_Tests ( void   )

USBHost_Tests attempts to access and write a file on USB stick.

It will mount the file system, then attempt to write a simple file on the USB interface.

Definition at line 579 of file SmartBoard_Tester.cpp.


Variable Documentation

const char* TicTocServer = "ntp.okstate.edu"

!< Used as the console for interactively reporting progress

Definition at line 29 of file SmartBoard_Tester.cpp.

const int tzOffsetHr = -6

!< time server since it is closer than "0.uk.pool.ntp.org"

Definition at line 30 of file SmartBoard_Tester.cpp.

const int tzOffsetMin = 0

!< time zone offset hours to print time in local time

Definition at line 31 of file SmartBoard_Tester.cpp.