Skip to content
Permalink
Browse files

initial upload of code and basic readme creation.

  • Loading branch information...
EasonNYC committed Jul 16, 2015
0 parents commit 5c0d128d6cf88232640a3478b118a0a502da4845
Showing with 1,387 additions and 0 deletions.
  1. +222 −0 .gitignore
  2. +22 −0 Alarm.cpp
  3. +20 −0 Alarm.h
  4. +108 −0 Communication.cpp
  5. +29 −0 Communication.h
  6. +172 −0 Controls.cpp
  7. +39 −0 Controls.h
  8. +90 −0 Defines.h
  9. +24 −0 Heartbeat.cpp
  10. +22 −0 Heartbeat.h
  11. +126 −0 Motor.cpp
  12. +43 −0 Motor.h
  13. +1 −0 README.md
  14. +45 −0 Robot.ino
  15. +65 −0 Sensor.cpp
  16. +38 −0 Sensor.h
  17. +30 −0 Timer.cpp
  18. +19 −0 Timer.h
  19. +34 −0 Watchdog.cpp
  20. +24 −0 Watchdog.h
  21. +186 −0 Wifly.cpp
  22. +28 −0 Wifly.h
@@ -0,0 +1,222 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Vv]isual Micro/
[Rr]obot_ino/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/

# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
project.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

#visual studio other
*.vcxproj
*.filters
*.sln
*.user

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

#text files for logs
*.txt

#class diagrams in MSVS
*.cd
@@ -0,0 +1,22 @@
#include "Communication.h"
#include "Alarm.h"

namespace Robot
{
Alarms::Alarms() //initialize all arrays to zero and comm pointer to null since communications needs an alarm ref to initialize
:comm(NULL)
{}
void Alarms::send(int code) //takes in an integer input and sends all qued messages, adds the alarm code and then sends that
{
if (comm) //only run if comm pointer is set
{
comm->sendComm(); //flush the cue
comm->addComm('!', 2, NULL, &code); //add the alarm to the cue
comm->sendComm(); //send the cue with the alarm
}
}
void Alarms::setComms(Communication& comm) //when you get a chance explain why this doesnt happen in the constructor instead.
{
this->comm = &comm;
}
}
20 Alarm.h
@@ -0,0 +1,20 @@
#ifndef ALARM_H
#define ALARM_H

#include "Defines.h"

namespace Robot
{
class Communication;

class Alarms
{
private:
Communication* comm; //communications pointer to send messages
public:
Alarms();
void send(int code);
void setComms(Communication& comm);
};
}
#endif
@@ -0,0 +1,108 @@
#include "Watchdog.h"
//#include "Alarm.h"
#include "Controls.h"
#include "Communication.h"

namespace Robot
{
Communication::Communication(Watchdog& wdt, Controls& control /*, Alarms& alarms*/)
:watchdog(&wdt), control(&control) //, alarm(&alarms)
{}
void Communication::clear(char* arr) //used to reset (input or output) arrays to zero. should we use NULL instead of zero?
{
for (int i = 0; i < 20; i++)
arr[i] = 0;
}

//add a message to the cue (byte version)
void Communication::addComm(const char ID, const byte length, byte* message, int* mess)
{
if (length >(maxcols - 3)){
//alert
//return from function? or increase length?
}

//look for first empty row
for (int i = 0; i < maxrows; i++){
if (output[i][0] != '#')
{ //if this is a clear row
output[i][0] = '#'; //this row now has a message
output[i][1] = length + 1; //length plus id is the total message length
output[i][2] = ID; //store the id
if (message != NULL)
{
for (int x = 0; x < length; x++){ //start at just past id and store rest of message
output[i][x + 3] = message[x];
}
}
else
{
for (int x = 0, y = 0; x < (length / 2); x++, y += 2)
{
output[i][y + 3] = highByte(mess[x]);
output[i][y + 4] = lowByte(mess[x]);
}
}
//this->display(output[i]);
break; //important to break here
}
}
}
void Communication::display(char* arr) //will display input and output buffers for debug purposes
{
for (int i = 0; i < 20; i++)
{
Serial.print(arr[i]);
Serial.print(", ");
}
Serial.println(" ");
}
//function for receiving incoming messages from labview. returns a pointer to the message.
void Communication::recComm()
{
if (Serial3.available()) //if wifly sent something
{
watchdog->reset(); //we're connected so reset the watchdog
this->in = Serial3.read(); //get 1 byte

if (this->in == commBegin) //if this is the start of a valid message. all communications from labview begin with '$' (defined as commBegin)
{
int x = 0;
for (int i = 0; ((this->in != commEnd) && (i < maxcols)); i++)
{
delay(1); //will be removed once baud rate on arduino and wifly is up'd
this->in = Serial3.read(); //read next incoming byte
input[i] = this->in; //store it. these 2 lines can probably be combined
x++;
}
this->checksumNumber = input[x - 2];
Serial.println();
//Serial << this->checksumNumber << " " << this->checkSum(input, x) << endl;
}
//alarm->ack(input);
control->updateControls(input);
this->display(input); //for debug
this->clear(input);
}
}
byte Communication::checkSum(char* arr, int end)
{
byte CRC;
for (int i = 0; i < end - 2; i++)
CRC = CRC ^ arr[i];
return CRC;
}
//send out all messages in the outgoing message cue
void Communication::sendComm()
{
for (int i = 0; output[i][0] == commStart; i++) //will write to serial3 only the non empty arrays
{
//this->display(output[i]);
int length = byte(output[i][1]); //temp variable to store the length of the payload
for (int x = 0; x < length; x++)
Serial3.write(output[i][x + 2]); //ignore the first 2 bytes(not used by labview), and send everything afterwords.
this->clear(output[i]); //finish by clearing that message after it has been sent
}
}

}
Oops, something went wrong.

0 comments on commit 5c0d128

Please sign in to comment.
You can’t perform that action at this time.