Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 15
61  Using Arduino / Displays / Re: GLCD library version 3 on: January 01, 2012, 02:30:02 pm
Move this:
Code:
static FontCallback FontRead;               // font callback shared across all instances
from gText.h to the top of gText.cpp. Put it just above:
Code:
/*
 * Experimental defines
 */
at line 35
Thanks. That's great. Job done.

Quote
There are a few others, I'll also get rid of.
I'm not sure I can get rid of the warnings about the progmem stuff used by the fonts though.
Not seeing any others here at present.

Iain
62  Using Arduino / Displays / Re: GLCD library version 3 on: January 01, 2012, 12:53:12 pm
Bill,

Is there any way to suppress this warning message produced by gText.h?

Arduino-1.0\libraries\glcd/include/gText.h:171: warning: 'FontRead' defined but not used

Iain
63  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: January 01, 2012, 08:38:06 am
Lets hope you've got enough free time to get it all done smiley

Iain
64  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: January 01, 2012, 07:58:55 am
An efficient copy of the write methods would be good. I've also discovered that accessing the SerialPort class via Stream* is bad for performance. The message which took 168us before, takes 244us via Stream*. I'm guessing that's due to the extra indirection caused by virtual functions. So having efficient write methods in SerialPort would be excellent.

Iain
65  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: January 01, 2012, 06:58:14 am
I'd like to know if it's possible to have a faster method to upload a string to the the transmit buffer.

In my system I have a maximum processing time of 390us. This all works well but when debugging, the amount of text output causes the timing to be exceeded. I was hoping that a larger output buffer would help. It's definitely an improvement over HardwareSerial.

I've been testing with a 29 character message and HardwareSerial took 892us to send the message. Using SerialPort with a transmit buffer size of 32 bytes it's down to 168us. However just doing a memory copy takes 16us.

So I've been wondering if there's a way to allow the SerialPort class to have a fast copy into the transmit buffer?

Code:
#include <SerialPort.h>

SerialPort<0, 0, 32> port;

void setup(void)
{
port.begin(115200);
for (int route = 0; route < 11; route++)
{
uint32_t start;

start = micros();
DebugPrintLine("Selecting passenger route x");
ShowMessageTime(start, micros());
start = micros();
DebugPrintLine2("Selecting passenger route x");
ShowMessageTime(start, micros());
}
}

void loop(void)
{
}

void DebugPrintLine(const char* message)
{
while (*message != '\0')
{
port.write(*message++);
}

port.write('\r');
port.write('\n');
}

void DebugPrintLine2(const char* message)
{
char buffer[50];
char* dest = buffer;

while (*dest++ = *message++)
;

*dest++ = '\r';
*dest++ = '\n';
}

void ShowMessageTime(uint32_t start, uint32_t stop)
{
port.print("Message time:");
port.print(stop - start, DEC);
port.println("us");
delay(400);
}

Iain
66  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: January 01, 2012, 06:53:45 am
Thanks for the fix. It's all working correctly now.

Iain
67  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: January 01, 2012, 04:03:09 am
Do you have anything connected to port1?  If nothing is connected, you could get really high speed framing errors on port1 from noise.

I put a wire in RX1 and get your result and the RX1 buffer is full of junk.

You could try connecting RX1 to 5V so it appears to be connected to an idle port.  Serial ports idle HIGH.

Edit: There is a bug when the RX1 buffer is full.  I don't clear the interrupt when I can't buffer the character.
That would explain my issue. Another Mega is connected to serial port 1 and it streams data continuously. So when this Mega starts up, before I can do anything the port will be full. I'll check out the fix when I power up the complete system and report back.

Thanks for your efforts. Glad you could figure it out from my incomplete ramblings. I hadn't realised the importance of my system since I was seeing timing issues on Serial0, and only discovered that Serial1 was required well after midnight.

Iain
68  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 08:36:10 pm
Just run it again and it's not going wrong here either. I'll have another look in the morning.

Iain
69  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 08:29:18 pm
I've run it on two different Mega's and that's not what I get. :-((
70  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 07:45:16 pm
Looks like I didn't clean up the code correctly. Remove the SerialPort<> declaration inside setup().

Here's the cleaner version:
Code:
#include <SerialPort.h>

static SerialPort<0, 0, 256> serialPort;
static SerialPort<1, 16, 16> serialPort1;

void setup(void)
{
serialPort.begin(115200);
serialPort1.begin(115200);
for (int route = 0; route < 11; route++)
{
uint32_t start, stop;

start = micros();
stop = micros();
serialPort.print(stop - start, DEC);
serialPort.println("us");
delay(400);
}
}

void loop(void)
{
}

Iain
71  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 07:42:14 pm
There could very well be bugs so let me know if you find a slowdown problem.  I only put two days into this so far.  I haven't done much testing.

I put this code out so I could get comments while I am early in development.  I really appreciate suggestions like robtillaart's suggestion to add parity, character size, and stop-bit options.  Also to return error information for parity, framing, receiver overruns, and buffer overruns.
OK. It's taken a while to isolate the problem. It seems that creating the second serial port is causing all the problems. This simple program demonstrates the problem. I've no idea what's causing it but if you don't add the SerialPort<1, 16, 16> but it's fine. No idea if the parameters are important. Each loop should report either 0us or 4us. However after the first loop, it reports 156us each time. I'm guessing something in an interrupt is eating all my cycles.

Code:
#include <SerialPort.h>

static SerialPort<0, 0, 256> serialPort;
static SerialPort<1, 16, 16> serialPort1;

void setup(void)
{
SerialPort<0, 0, 256> serialPort;

serialPort.begin(115200);
serialPort1.begin(115200);
for (int route = 0; route < 11; route++)
{
uint32_t start, stop;

start = micros();
stop = micros();
serialPort.print(stop - start, DEC);
serialPort.println("us");
delay(400);
}
}

void loop(void)
{
}

Hope that helps.

Iain
72  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 06:08:54 pm
I take that back. I've just written a simple test program to access via Stream* and buffering still happens.

I'd assumed the slowdown in my original app (when I used SerialPort) was due to a lack of buffering. That's not the case so I'll have a good look at my code.

Iain
73  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 05:52:59 pm
But not if you access it via Stream*.

Iain
74  Development / Other Software Development / Re: An alternative Serial Library for Arduino 1.0 on: December 31, 2011, 04:12:55 pm
I've been playing with this for most of the afternoon and think I've found a problem. I'm accessing the serial port code via Stream* so that I don't know whether it's HardwareSerial or SerialPort. However the Stream overrides in SerialPort aren't marked virtual.

I'm not seeing any buffering here when I write to the serial port.

Checking out the code I see you've gone for inlining everywhere you can. Unfortunately inlining with virtual functions can cause problems, actually taking more code space than when not inlining.

Iain
75  Using Arduino / Displays / Re: GLCD library version 3 on: December 30, 2011, 04:24:17 am
Bill,

Thanks for the detailed reply. I did read the release notes when I downloaded it but forgot to check again before posting. I was porting some old 0021 code to 1.0. I'll switch to print. To get it going I just added a cast (const prog_char*) to my F() macro.

Iain
Pages: 1 ... 3 4 [5] 6 7 ... 15