mirror of
https://github.com/ole00/afterburner.git
synced 2025-01-15 08:29:45 +00:00
version 0.4 - baud rate changed to 57600. Please re-upload .ino sketch.
After testing with genuine arduino uno I could not make it to work reliably using the original baudrate 38400 on Windows 7. Linux worked OK, but Windows 7 inserted extra 2 bytes 0xFE or 0xFF at the beginnig of the serial communication (at least that's what arduino read from the serial line). Baudrate 57600 so far had no issue, another reliable option seem to be 9600.
This commit is contained in:
parent
443072e423
commit
b5d6fa6683
@ -253,12 +253,13 @@ void printHelp(char full) {
|
||||
// setup the Arduino board
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(38400);
|
||||
Serial.begin(57600);
|
||||
isUploading = 0;
|
||||
endOfLine = 0;
|
||||
echoEnabled = 0;
|
||||
mapUploaded = 0;
|
||||
typeCheck = 1; //do type check
|
||||
lineIndex = 0;
|
||||
|
||||
// Serial output from the GAL chip, input for Arduino
|
||||
pinMode(PIN_SDOUT, INPUT);
|
||||
|
@ -51,7 +51,7 @@ To compile: gcc -g3 -O0 afterburner afterburner.c
|
||||
|
||||
#include "serial_port.h"
|
||||
|
||||
#define VERSION "v.0.3.1"
|
||||
#define VERSION "v.0.4"
|
||||
|
||||
|
||||
#define MAX_LINE 200
|
||||
@ -466,7 +466,7 @@ static char readJedec(void) {
|
||||
}
|
||||
|
||||
static int openSerial(void) {
|
||||
char buf[512];
|
||||
char buf[512] = {0};
|
||||
char devName[256] = {0};
|
||||
int total;
|
||||
int labelPos;
|
||||
@ -596,8 +596,13 @@ static int waitForSerialPrompt(char* buf, int bufSize, int maxDelay) {
|
||||
}
|
||||
}
|
||||
if (maxDelay > 0) {
|
||||
/* WIN_API handles timeout itself */
|
||||
#ifndef _USE_WIN_API_
|
||||
usleep(3 * 1000);
|
||||
maxDelay -= 3;
|
||||
#else
|
||||
maxDelay -= 30;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return bufPos;
|
||||
|
@ -37,18 +37,26 @@ static inline SerialDeviceHandle serialDeviceOpen(char* deviceName) {
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
dcbSerialParams.BaudRate = CBR_38400; // Setting BaudRate = 38400
|
||||
dcbSerialParams.BaudRate = CBR_57600; // Setting BaudRate
|
||||
dcbSerialParams.ByteSize = 8; // Setting ByteSize = 8
|
||||
dcbSerialParams.StopBits = ONESTOPBIT;// Setting StopBits = 1
|
||||
dcbSerialParams.Parity = NOPARITY; // Setting Parity = None
|
||||
dcbSerialParams.fOutxCtsFlow = FALSE;
|
||||
dcbSerialParams.fOutxDsrFlow = FALSE;
|
||||
dcbSerialParams.fDtrControl = DTR_CONTROL_DISABLE;
|
||||
dcbSerialParams.fOutX = FALSE;
|
||||
dcbSerialParams.fInX = FALSE;
|
||||
dcbSerialParams.fRtsControl = RTS_CONTROL_DISABLE;
|
||||
dcbSerialParams.fBinary = TRUE;
|
||||
|
||||
|
||||
result = SetCommState(h, &dcbSerialParams);
|
||||
if (!result) {
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
timeouts.ReadIntervalTimeout = 50; // in milliseconds
|
||||
timeouts.ReadTotalTimeoutConstant = 50; // in milliseconds
|
||||
timeouts.ReadIntervalTimeout = 30; // in milliseconds
|
||||
timeouts.ReadTotalTimeoutConstant = 30; // in milliseconds
|
||||
timeouts.ReadTotalTimeoutMultiplier = 10; // in milliseconds
|
||||
timeouts.WriteTotalTimeoutConstant = 50; // in milliseconds
|
||||
timeouts.WriteTotalTimeoutMultiplier = 10; // in milliseconds
|
||||
@ -57,6 +65,8 @@ static inline SerialDeviceHandle serialDeviceOpen(char* deviceName) {
|
||||
if (!result) {
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
//ensure no leftover bytes exist on the serial line
|
||||
result = PurgeComm(h, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);
|
||||
|
||||
return h;
|
||||
} else {
|
||||
@ -128,8 +138,8 @@ static inline SerialDeviceHandle serialDeviceOpen(char* deviceName) {
|
||||
struct termios serial;
|
||||
|
||||
memset(&serial, 0, sizeof(struct termios));
|
||||
cfsetispeed(&serial, B38400);
|
||||
cfsetospeed(&serial, B38400);
|
||||
cfsetispeed(&serial, B57600);
|
||||
cfsetospeed(&serial, B57600);
|
||||
|
||||
serial.c_cflag |= CS8; // no parity, 1 stop bit
|
||||
serial.c_cflag |= CREAD | CLOCAL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user