Advertisement
UnaClocker

Datalog sketch pre-alpha

May 5th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. // Datalogger attempt
  2. /* Quote by Shel-Game:
  3.  The simple way to get in is the code 12 test.
  4.  Basically, you send the SBEC 0x12 at 7815 baud until
  5.  it replies with 0x12. Then you switch the baud to
  6.  62500 and re-send the 0x12 to confirm the datalogging mode.
  7.  After that, the SBEC is in datalogging mode until you
  8.  key it off. Once in datalogging mode, you simply send
  9.  a single byte memory location and it replies with the data
  10.  at that location. Pretty simple really.
  11.  */
  12. byte tempByte=0;
  13.  
  14.  
  15. void setup() {
  16.   pinMode(13, OUTPUT);
  17.  
  18.   Serial.begin(9600);
  19.   Serial3.begin(7815);
  20.   while(!Serial3.available()) {
  21.     Serial.print("Attempting");
  22.     Serial3.print(0x12);
  23.     delay(50);
  24.   }
  25.   while (Serial3.available()) {
  26.     tempByte=Serial3.read();
  27.  
  28.     if (Serial3.available()) {
  29.       byte temp = Serial3.read();
  30.       if (temp==0x12) {
  31.         Serial.println("");
  32.  
  33.         Serial.println("First contact, success!");
  34.         Serial3.end();
  35.         Serial3.begin(62500);
  36.         Serial3.print(0x12);
  37.         digitalWrite(13, HIGH);
  38.         delay(100);
  39.         Serial3.flush();
  40.       }    
  41.       else {
  42.         Serial.print("Failed.");
  43.         delay(1000);
  44.       }
  45.     }
  46.   }
  47. }
  48.  
  49. void loop() {
  50.   for (byte memoryLocation = 0; memoryLocation<=255; memoryLocation++) {
  51.     Serial.print("Memory Location: ");
  52.     Serial.print(memoryLocation, HEX);
  53.     Serial3.print(memoryLocation);
  54.     delay(50);
  55.     if (Serial3.available()) {
  56.  
  57.  
  58.       Serial.print("    Content: ");
  59.       Serial.println(Serial3.read(), HEX);
  60.       delay(100);
  61.     } else {
  62.       Serial.println("  No Reply");
  63.       }
  64.   }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement