removed other directories

pull/1/head
Alan Johnston 7 years ago
parent d6c16123aa
commit d902e4b159

@ -1,116 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.968018752">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.968018752" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.968018752" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.968018752." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.1587531182" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.277763213" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
<builder buildPath="${workspace_loc:/piglatin}/Debug" id="cdt.managedbuild.tool.gnu.builder.mingw.base.463655558" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1212045008" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.618072250" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1183093055" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.1657939728" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug">
<option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.1750532442" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.881571773" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.1807393689" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.1155945581" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.160981379" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1662705351" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ax5043}&quot;"/>
</option>
<option id="gnu.c.compiler.option.warnings.extrawarn.1401796605" name="Extra warnings (-Wextra)" superClass="gnu.c.compiler.option.warnings.extrawarn" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.pedantic.331198272" name="Pedantic (-pedantic)" superClass="gnu.c.compiler.option.warnings.pedantic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.warnings.wconversion.1567714141" superClass="gnu.c.compiler.option.warnings.wconversion" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2091055915" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.422900460" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug">
<option id="gnu.c.link.option.libs.2058602290" name="Libraries (-l)" superClass="gnu.c.link.option.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="ax5043"/>
</option>
<option id="gnu.c.link.option.paths.1962990162" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/ax5043/Debug}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1713763613" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.1203633911" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.1623410703">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.1623410703" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.1623410703" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release">
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.1623410703." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.1866354020" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release">
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.105564088" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/>
<builder buildPath="${workspace_loc:/piglatin}/Release" id="cdt.managedbuild.tool.gnu.builder.mingw.base.1979410991" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.733683903" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1007297814" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1254805440" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.1215927784" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release">
<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.923740630" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.301070439" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.708764682" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.39752458" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.604168124" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1754101218" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.1339434463" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.476910053" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.1187309384" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="piglatin.cdt.managedbuild.target.gnu.mingw.exe.288684248" name="Executable" projectType="cdt.managedbuild.target.gnu.mingw.exe"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.968018752;cdt.managedbuild.config.gnu.mingw.exe.debug.968018752.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.1807393689;cdt.managedbuild.tool.gnu.c.compiler.input.2091055915">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1623410703;cdt.managedbuild.config.gnu.mingw.exe.release.1623410703.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.708764682;cdt.managedbuild.tool.gnu.c.compiler.input.1754101218">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

@ -1 +0,0 @@
/Debug/

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>piglatin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.debug.968018752" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1896922210155201054" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="cdt.managedbuild.config.gnu.mingw.exe.release.1623410703" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="1896922210155201054" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>

@ -1,11 +0,0 @@
eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/CPATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/C_INCLUDE_PATH/delimiter=;
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/appendContributed=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/LIBRARY_PATH/delimiter=;
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/LIBRARY_PATH/operation=remove
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/append=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.968018752/appendContributed=true

@ -1,426 +0,0 @@
// Copyright (c) 2018 Brandenburg Tech, LLC
// All right reserved.
//
// THIS SOFTWARE IS PROVIDED BY BRANDENBURG TECH, LLC AND CONTRIBUTORS
// ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BRANDENBURT TECH, LLC
// AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <axradio/axradioinit_p.h>
#include <axradio/axradiomode_p.h>
#include <axradio/axradiorx_p.h>
#include <axradio/axradiotx_p.h>
#include <ctype.h>
#include <generated/configtx.h>
#include <spi/ax5043spi_p.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define FALSE (0)
#define TRUE (1)
#define MAX_MESSAGE_LENGTH (197)
#define MAX_INPUT_LENGTH (1024)
#define MAX_WORD_LENGTH (192)
extern uint8_t axradio_rxbuffer[];
void receive(void);
void transmit(uint8_t *word, size_t length);
void toPigLatin(uint8_t *input);
void readWord(uint8_t *word, unsigned int wordLength, uint8_t **input);
void wordToPigLatin(uint8_t *word, unsigned int wordLength);
void wordToPigLatinVowel(uint8_t *word, unsigned int srcLoc, uint8_t workWord[],
unsigned int destLoc, unsigned int wordLength);
void wordToPigLatinConsonant(uint8_t firstLetter, uint8_t *word, unsigned int srcLoc,
uint8_t *workWord, unsigned int destLoc, unsigned int wordLength);
enum RadioState {UnknownState, RxState, TxState};
enum RadioState currentState = UnknownState;
enum ReceiveState {WaitingForNewPacket, WaitingForPacketCounter1,
WaitingForPacketCounter2, WaitingForMessageLength1,
WaitingForMessageLength2, WaitingForMessage,
WaitingForChecksum1, WaitingForChecksum2};
int main(void)
{
uint8_t retVal;
// Configure SPI bus to AX5043
setSpiChannel(SPI_CHANNEL);
setSpiSpeed(SPI_SPEED);
initializeSpi();
// Initialize the AX5043
retVal = axradio_init();
if (retVal == AXRADIO_ERR_NOCHIP) {
fprintf(stderr, "ERROR: No AX5043 RF chip found\n");
exit(EXIT_FAILURE);
}
if (retVal != AXRADIO_ERR_NOERROR) {
fprintf(stderr, "ERROR: Unable to initialize AX5043\n");
exit(EXIT_FAILURE);
}
printf("INFO: Found and initialized AX5043\n");
printf("This utility receives text from another transmitter,\n");
printf("translates it to pig Latin, then transmits the translation\n");
receive();
return 0;
}
void receive(void) {
uint8_t retVal;
uint16_t packetNumber;
uint16_t messageLength;
uint16_t checksum;
uint8_t ch;
// Allocate space for the translation. I'm choosing to use an array of
// "reasonable" length
uint8_t input[MAX_INPUT_LENGTH];
uint16_t currentLetter = 0;
input[currentLetter] = '\0';
enum ReceiveState currentReceiveState = WaitingForNewPacket;
for (;;) {
// Enter receive mode only if not already in receive mode
if (currentState != RxState) {
retVal = mode_rx();
if (retVal != AXRADIO_ERR_NOERROR) {
fprintf(stderr, "ERROR: Unable to enter RX mode\n");
exit(EXIT_FAILURE);
}
currentState = RxState;
}
retVal = receive_packet();
if (retVal > 0) {
uint8_t counter = 0;
while (retVal-- > 0) {
switch(currentReceiveState) {
case WaitingForNewPacket:
printf("Pkt Len: %d\n", (int)axradio_rxbuffer[counter++]);
currentReceiveState = WaitingForPacketCounter1;
break;
case WaitingForPacketCounter1:
packetNumber = (int)axradio_rxbuffer[counter++];
currentReceiveState = WaitingForPacketCounter2;
break;
case WaitingForPacketCounter2:
packetNumber |= (uint16_t)(axradio_rxbuffer[counter++] << 8);
printf("Pkt Num: %d\n", (int)packetNumber);
currentReceiveState = WaitingForMessageLength1;
break;
case WaitingForMessageLength1:
messageLength = (int)axradio_rxbuffer[counter++];
currentReceiveState = WaitingForMessageLength2;
break;
case WaitingForMessageLength2:
messageLength |= (uint16_t)(axradio_rxbuffer[counter++] << 8);
printf("Msg Len: %d\n", (int)messageLength);
currentReceiveState = WaitingForMessage;
currentLetter = 0;
input[currentLetter] = '\0';
printf("receive: ");
break;
case WaitingForMessage:
ch = axradio_rxbuffer[counter++];
input[currentLetter] = ch;
currentLetter++;
input[currentLetter] = '\0';
if (ch != '\n') {
printf("%c", ch);
}
else {
//printf(" ");
printf("\n");
toPigLatin(input);
currentReceiveState = WaitingForChecksum1;
}
break;
case WaitingForChecksum1:
checksum = (int)axradio_rxbuffer[counter++];
currentReceiveState = WaitingForChecksum2;
break;
case WaitingForChecksum2:
checksum |= (uint16_t)(axradio_rxbuffer[counter++] << 8);
printf("Chksum: %d\n", (int)checksum);
currentReceiveState = WaitingForNewPacket;
break;
default:
fprintf(stderr, "ERROR: Unknown state in receive state machine\n");
exit(EXIT_FAILURE);
break;
}
}
}
usleep(25000);
}
}
void transmit(uint8_t *word, size_t length) {
uint8_t retVal;
// allocate space for the buffer
static uint8_t packet[MAX_MESSAGE_LENGTH + 1];
static uint16_t pkt_counter = 0;
++pkt_counter;
// Calculate the number of reserved bytes at the beginning of the packet
size_t reserved_space = 0;
// if transmitting a packet counter, reserve two bytes
if (framing_insert_counter) {
reserved_space += 2;
}
// reserve two bytes for the overall length of the packet including the
// packet counter, if present, and the field containing the length
reserved_space += 2;
size_t msg_length = 0;
// get a message to transmit.
//msg_length = get_message(&packet[reserved_space], (MAX_MESSAGE_LENGTH + 1) - reserved_space);
msg_length =
length <= (MAX_MESSAGE_LENGTH + 1) - reserved_space ? length : (MAX_MESSAGE_LENGTH + 1) - reserved_space;
strncpy((char*)&packet[reserved_space], (char*)word, msg_length);
// if message consists only of a newline, terminate
if (msg_length <= 1) {
return;
}
if (framing_insert_counter) {
packet[framing_counter_pos] = (uint8_t)(pkt_counter & 0xFF);
packet[framing_counter_pos+1] = (uint8_t)((pkt_counter>>8) & 0xFF);
// include the message length
packet[framing_counter_pos+2] = (uint8_t)(msg_length & 0xFF);
packet[framing_counter_pos+3] = (uint8_t)((msg_length>>8) & 0xFF);
}
else { // only include the message length
packet[framing_counter_pos] = (uint8_t)(msg_length & 0xFF);
packet[framing_counter_pos+1] = (uint8_t)((msg_length>>8) & 0xFF);
}
// Enter transmit mode only if not already in receive mode
if (currentState != TxState) {
retVal = mode_tx();
if (retVal != AXRADIO_ERR_NOERROR) {
fprintf(stderr, "ERROR: Unable to enter TX mode\n");
exit(EXIT_FAILURE);
}
currentState = TxState;
}
//printf("INFO: Sending another packet...\n");
//printf("DEBUG: msg_length = %d\n", msg_length);
//printf("DEBUG: reserved_space = %d\n", reserved_space);
retVal = transmit_packet(&remoteaddr_tx, packet, (uint16_t)(msg_length + reserved_space));
if (retVal != AXRADIO_ERR_NOERROR) {
fprintf(stderr, "ERROR: Unable to transmit a packet\n");
exit(EXIT_FAILURE);
}
usleep(100000);
}
void toPigLatin(uint8_t *input) {
//printf("input: %s\n", input);
// Allocate space for a word. I'm choosing to use an array of
// "reasonable" length
uint8_t word[MAX_WORD_LENGTH];
word[0] = '\0';
readWord(word, MAX_WORD_LENGTH, &input);
//printf("word: %s\n", word);
// While there are still words...
while (strlen((char*)word) > 0) {
// convert the word to pig latin
wordToPigLatin(word, MAX_WORD_LENGTH);
strcat((char*)word, "\n");
printf("%s", word);
transmit(word, strlen((char*)word));
// get the next word
readWord(word, MAX_WORD_LENGTH, &input);
//printf("word: %s\n", word);
}
}
void readWord(uint8_t *word, unsigned int wordLength, uint8_t **input) {
// initialize the word to zero length
unsigned int currentLoc = 0;
if (wordLength == 0) {
printf("ERROR: Internal error. No buffer allocated for word\n");
return;
}
word[currentLoc] = '\0';
// Examine the first character.
uint8_t ch;
ch = **input;
(*input)++;
// If it is a newline, we have no more words, so
// read and throw away the newline. That's all we need
// to do
if (ch == '\n') {
// do nothing
}
else {
int foundNonWhiteSpace = FALSE;
// loop until we find our first non-white space
// character and then the first white-space character
// after that. That means we found a word and
// the end of that word
while (((!foundNonWhiteSpace || !isspace(ch))) && ch != '\n') {
if (wordLength == 0) {
printf("WARNING: Word is too long for buffer. Breaking up the word.\n");
return;
}
if (!isspace(ch)) {
foundNonWhiteSpace = TRUE;
}
word[currentLoc++] = ch;
word[currentLoc] = '\0';
// Get the next letter
ch = **input;
(*input)++;
}
// Push the white space character back into the input buffer
(*input)--;
}
}
void wordToPigLatin(uint8_t *word, unsigned int wordLength) {
// allocate working space for a word
uint8_t *workWord = malloc(wordLength);
workWord[0] = '\0';
unsigned int srcLoc = 0;
unsigned int destLoc = 0;
// copy over any leading whitespace
while(word[srcLoc] && srcLoc < wordLength && isspace(word[srcLoc])) {
workWord[destLoc++] = word[srcLoc++];
workWord[destLoc] = '\0';
}
// Look at the next character
uint8_t ch = word[srcLoc];
// If it is a vowel...
if (tolower(ch) == 'a' || tolower(ch) == 'e' || tolower(ch) == 'i' ||
tolower(ch) == 'o' || tolower(ch) == 'u') {
// process a word beginning with a vowel
wordToPigLatinVowel(word, srcLoc, workWord, destLoc, wordLength);
}
// If it is a consonant...
else if (isalpha(ch)) {
// save that letter
uint8_t firstLetter = ch;
srcLoc++;
// Take care of the case of a one letter word
if (!word[srcLoc]) {
// Save the first character, unchanged to the destination
workWord[destLoc++] = ch;
workWord[destLoc] = '\0';
// Append "ay"
strcat((char*)workWord, "ay");
}
// else we have more than one letter
else {
// Process a word beginning with a consonant
wordToPigLatinConsonant(firstLetter, word, srcLoc, workWord,
destLoc, wordLength);
}
}
// else just copy over the word
else {
strcat((char*)workWord, (char*)&word[srcLoc]);
}
// Copy the workspace into our word
strncpy((char*)word, (char*)workWord, wordLength);
// Ensure it is null-terminated under all circumstances
if (strlen((char*)workWord) < wordLength - 1) {
word[strlen((char*)workWord)] = '\0';
}
else {
word[wordLength - 1] = '\0';
}
// Remember to free up the temporary workspace
free(workWord);
}
void wordToPigLatinVowel(uint8_t *word, unsigned int srcLoc, uint8_t workWord[],
unsigned int destLoc, unsigned int wordLength) {
// copy over the word
while (word[srcLoc] && srcLoc < wordLength) {
workWord[destLoc++] = word[srcLoc++];
workWord[destLoc] = '\0';
}
// append "way"
strcat((char *)workWord, "way");
}
void wordToPigLatinConsonant(uint8_t firstLetter, uint8_t *word, unsigned int srcLoc,
uint8_t *workWord, unsigned int destLoc, unsigned int wordLength) {
// Copy over the next letter, properly capitalizing it
if (isupper(firstLetter)) {
workWord[destLoc++] = (uint8_t)toupper(word[srcLoc++]);
workWord[destLoc] = '\0';
} else {
workWord[destLoc++] = (uint8_t)tolower(word[srcLoc++]);
workWord[destLoc] = '\0';
}
while (word[srcLoc] && srcLoc < wordLength) {
workWord[destLoc++] = word[srcLoc++];
workWord[destLoc] = '\0';
}
// Append what was previously the first letter
workWord[destLoc++] = (uint8_t)tolower(firstLetter);
workWord[destLoc] = '\0';
// Append "ay"
strcat((char*)workWord, "ay");
}
Loading…
Cancel
Save

Powered by TurnKey Linux.