<commit_before>#include <SoftwareSerial.h>

/**
 * How to use:
 * *** Use Arduino. V0p2 does not have high enough clock speed to run this program reliably ***
 * Set initialBaud to current SIM900 baud, or to 19200 if on autobaud
 * 'l' lists supported bauds
 * 'r' displays current baud
 * 's' sets a new baud
 */

SoftwareSerial ser(7,8);

static const char setBaudCommand[] = "AT+IPR";
static const uint16_t initialBaud = 19200;
static const uint16_t targetBaud  = 2400;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(4800);
  ser.begin(initialBaud);

  // power up shield
  pinMode(9, OUTPUT);
  digitalWrite(9, LOW);
  delay(500);
  digitalWrite(9, HIGH);
  delay(500);
  digitalWrite(9, LOW);
  delay(5000);
  while(ser.available() > 0) ser.read();

  setBaud();
}

void loop() {
  // put your main code here, to run repeatedly:
//  char c = 0;
//  if (Serial.available() > 0) c = Serial.read();
//  if (c == 'l') getPossibleBauds();
//  else if (c == 'r') getBaud();
//  else if (c == 's') setBaud();
  
  if (ser.available() > 0) Serial.print((char)ser.read());
}

void getPossibleBauds()
{
  Serial.println("\n++ List Supported Bauds ++");
  ser.write(setBaudCommand, sizeof(setBaudCommand)-1);
  ser.println("=?");
}

void getBaud()
{
  Serial.println("\n++ Current Baud ++");
  ser.write(setBaudCommand, sizeof(setBaudCommand)-1);
  ser.println("?");
}

void setBaud()
{
  Serial.print("\n++ Setting Baud to ");
  Serial.print(targetBaud);
  Serial.println(" ++");

  ser.write(setBaudCommand, sizeof(setBaudCommand)-1);
  ser.print("=");
  ser.println(targetBaud);

  ser.begin(targetBaud);

  //getRate();
}
<commit_msg>Mark's updated version of setSim900Baud<commit_after>#include <SoftwareSerial.h>

/**
 * How to use:
 * *** Use Arduino. V0p2 does not have high enough clock speed to run this program reliably ***
 * Set initialBaud to current SIM900 baud, or to 19200 if on autobaud
 * 'l' lists supported bauds
 * 'r' displays current baud
 * 's' sets a new baud
 */

SoftwareSerial ser(7, 8);

static const char setBaudCommand[] = "AT+IPR";
static const uint16_t initialBaud = 19200;
static const uint16_t targetBaud  = 2400;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(4800);
  ser.begin(initialBaud);

  // power up shield
  pinMode(9, OUTPUT);
  digitalWrite(9, LOW);
  delay(500);
  digitalWrite(9, HIGH);
  delay(500);
  digitalWrite(9, LOW);

  delay(5000);
  getBaud();
  delay(500);
  setBaud();
  delay(500);
  ser.begin(2400);
  delay(500);
  getBaud();
  while (ser.available() > 0) ser.read();

  delay(500);
  loop();
}

void loop() {
  // put your main code here, to run repeatedly:
  char c = 0;
  if (Serial.available() > 0) c = Serial.read();
  if (c == 'l') getPossibleBauds();
  else if (c == 'r') getBaud();
  else if (c == 's') setBaud();

  if (ser.available() > 0) Serial.print((char)ser.read());
}

void getPossibleBauds()
{
  Serial.println("\n++ List Supported Bauds ++");
  ser.write(setBaudCommand, sizeof(setBaudCommand) - 1);
  ser.println("=?");
}

void getBaud()
{
  Serial.println("\n++ Current Baud ++ - if correct you'll see <+IPR: 2400>");
  ser.write(setBaudCommand, sizeof(setBaudCommand) - 1);
  ser.println("?");
}

void setBaud()
{
  Serial.print("\n++ Setting Baud to ");
  Serial.print(targetBaud);
  Serial.println(" ++");

  ser.write(setBaudCommand, sizeof(setBaudCommand) - 1);
  ser.print("=");
  ser.println(targetBaud);

  ser.begin(targetBaud);

  //getRate();
}
{'fraction_non_alphanumeric': 0.17306590257879656, 'fraction_numerical': 0.03524355300859599, 'mean_word_length': 3.9030898876404496, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6189570', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1283, 'n_words': 341}