Amtrak Seattle to Olympia

A couple weekends ago I took Amtrak from Seattle’s King St., Station to Olympia Washington.

It cost less than gas money would have cost, $20 going down and $23 coming back.

The return trip was a bit of an experience.

I received a telephone call at 6:20 AM. When your phone rings in the middle of the night and wakes you up you debate whether to answer it. Then you’re likely to lie awake wondering who would’ve called you in the middle of the night. After coming to the conclusion that the only thing we can be on the phone at that time of the day is bad news you need to get up and figure out what the message was. In this case it turns out that it was 12 hours before my scheduled departure. Amtrak was calling to tell me that my train was delayed. Later when I checked on the website I found out that might train was delayed by four hours. There were trains scheduled two hours before and two hours after the train that I had selected. I called into the Amtrak number that would have been left on my voicemail message it was specifically for rescheduling reservations. The train before my schedule had no available seats the train after my schedule have one available seat and she was able to get me on that train with no fare change issues. The train I was scheduled on was currently running seven hours delayed.

I got to be looking station and have a normal uneventful trip back home.

Boarding the train in Olympia I was just told to take any available seat. Boarding the train in Seattle southbound you’re given explicit seat number that you’re supposed to sit in.

The people working the station in Olympia said that the through trains that start in San Diego quite often run late while the local trains that start in Oregon are more often on time.

Advertisements

Stack usage in C++ on embedded TMS320C6713 system

I spent a lot of time working on my embedded platform managing memory usage. Knowing how much stack is being used at any time was a major problem. It’s one thing to look at the assembly created by your code and be able to add up how much space each subroutine uses, but recognizing how much any other library function call uses is quite a differetn thing.

My solution was to have a routine that would initialize all of the ram in the stack to a particular pattern on the first call, and then measure how much of that ram was no longer the pattern on the second call.

extern void * _STACK_SIZE;
extern char * _stack;
int RFSAWStackCheck(char * InputBuffer, int InputBufferSize, const unsigned short LastSample, uart_init_struct &std_uart, FILE * tx)
{
	fprintf(tx,"%s\r\n",InputBuffer);
	fprintf(tx,"\t _STACK_SIZE = 0x%6x\r\n",(int)&_STACK_SIZE);
	fprintf(tx,"\t      _stack = 0x%6x\r\n",(int)&_stack);
	// Things to put in Watch Window:
	// _STACK_SIZE
	// _stack
	// B15
	// (_stack+_STACK_SIZE)-B15
	unsigned int * StackLow = (unsigned int *)&_stack;
	unsigned int * StackHigh = StackLow;
	while (*StackHigh == 0xDEADBEEF)
		StackHigh++;
	unsigned int StackUnused = (unsigned int)StackHigh - (unsigned int)StackLow;
	unsigned int StackUsed = (unsigned int)&_STACK_SIZE - StackUnused;
	fprintf(tx,"\t UnusedStack = 0x%6x\r\n",StackUnused);
	fprintf(tx,"\t   UsedStack = 0x%6x\r\n",StackUsed);
	if (InputBuffer[17] != '\0')
	{
		Uint32 gie = IRQ_globalDisable();
		fprintf(tx,"\t Writing to Stack Space = 0x%X\r\n",0xDEADBEEF);
		unsigned int ApproxCurrentStackUnused = (unsigned int)&ApproxCurrentStackUnused;
		// don't know exactly where my current variable lies in the current frame, and memset will require
		// a small amount of stack, simply for the function call itself.
		StackHigh = StackLow;
		while (StackHigh <= (unsigned int *)&ApproxCurrentStackUnused - 0x100)
			*StackHigh++ = 0xDEADBEEF;
		IRQ_globalRestore(gie);
	}
	return(0);
}

The two extern symbols _stack and _STACK_SIZE are automatically generated by the TI compiler toolset. The register B15 is the register that is used for the stack pointer.

I’m using a pattern that is human readable in hexadecimal, because it makes things easier when looking at a memory map in the debugger. 0xDEADBEEF is a simple 32 bit pattern that is not likely to occur naturally, but is quite recognizable to most english speakers.

I disable interrupts during the process of writing to the stack, but don’t do so during the process of reading from the stack. This is mostly a combination of me being lazy and the fact that I’m uncertain of possible implications of disabling interrupts.

I make a simple decision based on position 17 in the input buffer if I’m initializing the ram in the stack, or just looking to see how much of the pattern exists.

I’m interested in any feedback, suggestions of what I’m doing that’s unsafe, or better ways of accomplishing my goals.

New License Plates

Wim's License Plate

WIM

My earlier discussion of license plates and GoodToGo toll tags is now all moot, as I have new plates installed on my vehicle.

The interesting thing that I now need to do is to update information with GoodToGo, the parking garage management company, and possibly my insurance company. I wonder if there’s anyone else that I should really be notifying that I’ve changed the easiest identifier of my vehicle.