Hoping for a new start here. I've tried several versions of below, but any further entries past the 46th entry, including Case71() and below it, in the last section below (whether it's written as a switch/case or an if statement), and is always the same point. All variables are localized and set in each void, there are no other possible insertions of data or processes. The only thing that changes is the byte that is read from the Serial Device (slot machine) and can be a value of 0 to 155 (0x00 to 0x9B).
This has been written with either a single command entry (entering just a Case()) or with 15 lines of code with the same limited result of 46 variants. I've gone as far as commenting out the first section (any void with the term "SAS" in it) and still the second section cannot accept past the 46. There are no compile warnings or fails. Here's how much memory is used with ALL entries enabled, with no runtime.
Sketch uses 126698 bytes (49%) of program storage space. Maximum is 253952 bytes.
Global variables use 1657 bytes (20%) of dynamic memory, leaving 6535 bytes for local variables. Maximum is 8192 bytes.
Memory usage if I comment out beginning at entry #46 and then compile resulting in the program running:
Sketch uses 118814 bytes (46%) of program storage space. Maximum is 253952 bytes.
Global variables use 1655 bytes (20%) of dynamic memory, leaving 6537 bytes for local variables. Maximum is 8192 bytes.
Here's my setup and loop:
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <TextFinder.h>
//--- Items Requiring Global Usage
EthernetServer server(80);
//----- "Let's Roll!" - Todd Beamer, 09/11/2001 -----//
void setup() {
Serial.begin(19200);
Serial1.begin(19200);
if (!SD.begin(4)) {
;
return;
}
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
File myFile;
uint8_t ip[4];
myFile = SD.open("config.cfg"); {
if (myFile) {
ip[0] = myFile.parseInt();
ip[1] = myFile.parseInt();
ip[2] = myFile.parseInt();
ip[3] = myFile.parseInt();
}
myFile.close();
IPAddress ip (ip[0], ip[1], ip[2], ip[3]);
}
byte mac[] = {0xB0, 0x0B, 0xB0, 0x0B, 0xB0, 0x0B};
Ethernet.begin(mac, ip);
server.begin();
}
void loop() {
checkForClient();
getSASEvent();
}
Here's the two voids that process the single byte when no client is connected (running as a standalone). This works perfectly if the next section of code is clipped at 46 entries (written as either switch/case or if statements):
void getSASEvent() {
byte SASByte[0];
getSASCode(SASByte);
if (SASByte[0] == 61) {
byte SendByte[3];
byte RecvByte[35];
SendByte[0] = MachAdd;
SendByte[1] = 0x4D;
SendByte[2] = 0x00;
SendTypeS(SendByte, 5);
Serial1.readBytes(RecvByte, 35);
}
if (SASByte[0] == 81) {
byte SendByte[2];
byte RecvByte[24];
SendByte[0] = MachAdd;
SendByte[1] = 0x1B;
SendTypeR(SendByte, 2);
Serial1.readBytes(RecvByte, 24);
}
if (SASByte[0] == 87) {
byte SendByte[11];
byte RecvByte[10];
SendByte[0] = MachAdd;
SendByte[1] = 0x57;
SendTypeR(SendByte, 2);
Serial1.readBytes(RecvByte, 10);
SendByte[0] = MachAdd;
SendByte[1] = 0x58;
SendByte[2] = 0x01;
SendByte[3] = RecvByte[2];
SendByte[4] = 0x00;
SendByte[5] = 0x00;
SendByte[6] = RecvByte[3];
SendByte[7] = RecvByte[4];
SendByte[8] = RecvByte[5];
SendByte[9] = RecvByte[6];
SendByte[10] = RecvByte[7];
SendTypeS(SendByte, 13);
Serial1.readBytes(RecvByte, 5);
}
if (SASByte[0] == 103) {
byte SendByte[19];
byte RecvByte[21];
SendByte[0] = MachAdd;
SendByte[1] = 0x70;
SendTypeR(SendByte, 2);
Serial1.readBytes(RecvByte, 21);
SendByte[0] = MachAdd;
SendByte[1] = 0x71;
SendByte[2] = 0x10;
SendByte[3] = 0x00;
SendByte[4] = RecvByte[14];
SendByte[5] = RecvByte[15];
SendByte[6] = RecvByte[16];
SendByte[7] = RecvByte[17];
SendByte[8] = RecvByte[18];
SendByte[9] = 0x00;
SendByte[10] = RecvByte[10];
SendByte[11] = RecvByte[11];
SendByte[12] = RecvByte[12];
SendByte[13] = RecvByte[13];
SendByte[14] = RecvByte[14];
SendByte[15] = RecvByte[15];
SendByte[16] = RecvByte[16];
SendByte[17] = RecvByte[17];
SendByte[18] = RecvByte[18];
SendTypeS(SendByte, 21);
Serial1.readBytes(RecvByte, 21);
}
if (SASByte[0] == 104) {
byte SendByte[4];
byte RecvByte[6];
SendByte[0] = MachAdd;
SendByte[1] = 0x71;
SendByte[2] = 0x01;
SendByte[3] = 0xFF;
SendTypeS(SendByte, 6);
Serial.readBytes(RecvByte, 6);
}
if (SASByte[0] == 113) {
byte SendByte[7];
byte GSMACKNACK[1];
SendByte[0] = MachAdd;
SendByte[1] = 0x8A;
SendByte[2] = 0x00;
SendByte[3] = 0x01;
SendByte[4] = 0x00;
SendByte[5] = 0x00;
SendByte[6] = 0x00;
SendTypeS(SendByte, 9);
Serial1.readBytes(GSMACKNACK, 1);
}
}
void getSASCode(byte temp[]) {
Serial1.read();
UCSR1B = 0b10011101;
Serial1.write(0x80);
delay(20);
Serial1.write(0x81);
UCSR1B = 0b10011100;
Serial1.readBytes(temp, 1);
}
Here's the second area. No other actions in the rest of the code have any affect this:
void getStatusCode(byte temp[]) {
Serial1.read();
UCSR1B = 0b10011101;
Serial1.write(0x80);
delay(20);
Serial1.write(0x81);
UCSR1B = 0b10011100;
Serial1.readBytes(temp, 1);
}
This section of code calls the void shown above and it's only purpose is to display the Byte read (each Case()) with a client.println() statement from the Serial Device. This is the section that must be partially commented out for the program to run:
while (client.available()) {
byte StatusByte[0];
getStatusCode(StatusByte);
int StatusInt = StatusByte[0];
switch (StatusInt) {
case 17:
Case17();
break;
case 18:
Case18();
break;
case 19:
Case19();
break; (Had to clip due to 9000 character limit)
case 70:
Case70();
break;
/* case 71: <--- This entry and below must be commented out.
Case71();
break;
case 72:
Case72();
break; (Clipped to save characters)
case 154:
Case154();
break;
case 155:
Case155();
break; */