a b Dear Ryan, Your project description is excellent and I look forward to working with you. Best regards, Jens Jens, As a requirement for CS194 I have to write you a weekly progress email every week. This past week I spent most of my time setting up my environment on the samoa machine downstairs. I successfully downloaded and built Virgil and Avrora. After setting up those compilers I downloaded a few example Virgil programs and compiled them down to AVR code to run on the simulator. I attempted to use a few parameters on the simulator to get used it. After I got everything set up on the machine I started reading the TinyOS tutorial online. Unfortunately I was only able to read the first tutorial because after reading the first I attempted to write my own nesC program that used the LEDs as counters. I was unable to get my program to compile because of poor documentation on the nesC compiler. I plan on talking to Ben about this. This coming week I plan on brainstorming ideas for writing the analog to digital converter driver in order to interact with the sensor. In order to do this I plan on reading the documentation on the ADC and then studying the already existing nesC solutions. Also I'm going to have to study the Virgil timer implementation, since any driver written is going to have to interact with the timer for interrupts. At some point I plan on downloading the already existing Virgil code to the motes, but that won't happen until Ben can find somebody to help us. - Ryan From: Ryan Hall Date: Feb 5, 2007 3:10 PM Subject: Weekly Progress 2/5/2007 To: Jens Palsberg Jens, This past week I spent the majority of my time reading the ATMEL128 spec on the microcontroller to learn about the Analog to Digital Converter (ADC) and the 8-bit Timer (Timer0). After reading the specs, I studied the already implemented virgil library for the timer to start brainstorming ideas for the ADC driver. After meeting with Ben today, I cleared up some questions about virgil and have already started implementing the ADC driver. The driver is pretty much a mirror of the timer driver, with just different implementations for the same functions. Currently, the driver compiles, but is not running properly in the simulator. Hopefully this week I can fix the bugs in the driver and move on to finishing the sensor driver. - RyanJens, This week we worked on the ADC driver and after spending a considerable amount of time debugging it, we realized we were not setting the power pin to the light sensor. Before we realized that the ADC was always returning zero has its sample. In addition, we uncovered a bug in the simulator that was turning off interrupts, but that has now been fixed. We downloaded our ADC driver to the actual Mica2 board and from what we could see it worked! As we moved our hand over the light sensor, the LEDs changed. We wrote a program that had the LEDs display the last 3 bits of the light sensor value. Next week I plan on studying how to implement the SPI and UART drivers for the serial port. Once we get those working we'll be able to communicate with the Mica2 bidirectional and actually get debugging output from the board. One new idea I had over the weekend was to start using the monitors in the Avrora simulator to my advantage. A lot of time was wasted debugging the ADC driver and we could have found the bug quicker if we monitored the call stack of other similar programs. So this week in addition to reading the ATMEL documentation I plan on monitoring a view simulated serial port programs. - RyanDear Ryan, Your project description is excellent and I look forward to working with you. Best regards, JensJens, I wasn't able to work much on the project this week due school and a new grading job I picked up, but I did do some work yesterday and today. So far in the past 2 days I did some reading on the USART (Universal Synchronous and Asynchronous serial Receiver and Transmitter) device. Understanding the detailed spec of the USART actually took longer than I expected and consumed most of my time yesterday. After detailing the use of every register in the USART, I began coding the driver. So far I'm in the middle of it and I'm currently designing the best way to send and receive data from the serial port. I'm going to use a queue for the waiting data and I'm just trying to learn the best way to do it in virgil. Right now I have it implemented as a circular buffer, but I'll probably switch it to a linked list later to conserve memory space. I haven't met with Ben yet this week due to the holiday today and I'm not sure when I will due to some job interviews I have going on this week. A new idea I had this week was possibly adding more library support for virgil. I'm sure it would probably have a low priority on the "to do list", but it would make writing drivers easier and obviously applications. I know virgil has the ability to interact with other languages so maybe there would be a way to integrate the library support of java in virgil. I might talk this over with Ben when I meet with him this week to see what possibilities there are. - RyanFrom: Ryan Hall Date: Feb 26, 2007 3:57 PM Subject: Weekly Update 2-26-07 To: Jens Palsberg Jens, This week I continued working on the USART driver. I finalized my decision on a circular buffer for the receive and transmit queues after talking to Ben. Also Ben and I outlined an API for receiving and transmitting characters to the driver. Currently my code compiles and after several hours of debugging the code in the simulator I finally got the interrupts working. Now in order to test the code I am going to connect netcat to the simulator in order to transfer bytes back and forth. So this week I plan on reading a little bit about netcat in order to use it and then hopefully test my program. If this all works I'll download my code to the motes where I expect to run in to quite a bit of problems with properly configuring the device, since the simulator doesn't seem to care about that. Also this week I thought about implementing exceptions in Virgil. When debugging my code in the simulator I noticed that call stack would just abruptly stop on a "throw". After talking to Ben he explained to me that currently the virgil program will just stop. The use of exceptions will drastically reduce debugging time. For example it took me awhile to realize my object was null. That would be solved instantly in java. I think that inspired Ben because he wrote a new monitor that should help with that. I haven't tested it out yet though. That's all for now. Thanks, RyanFrom: Ryan Hall Date: Mar 5, 2007 3:45 PM Subject: Weekly Report 3-5-07 To: Jens Palsberg Jens, This week I finished up my work on the USART driver. I downloaded netcat and started playing around with it. Took a little bit of time to figure out how to send a data packet to the simulator. Once I got that done I was able to successfully transmit data from the simulator to netcat. This implementation only allowed one character to be sent at a time. I changed the transmit and receive APIs to work on character buffers. After debugging some problems with the Queue implementation, I successfully receive bytes and then transmit the bytes back out to netcat. You can send one character at a time or send a long sequence of characters at a time. For example you can send "this is a long sentence" and it will reply back with the same string. I wasn't able to meet with Ben about what to do next because he had to leave before I was done fixing my code. I plan on meeting with him sometime this week to figure that out. I'm guessing I'll try downloading the code to the actual mote and start debugging the configuration registers. One new thing I thought about this week was Virgil's limitation to dynamically allocate objects within a method. I'm sure this problem stems from the space optimization algorithms the compiler employs, but it would be nice to be able to do this. So far when I've run into this problem, I've been able to change the variable to a field and allocate its space in the constructor. But I'm wondering if this solution would not always work. - Ryan From: Ryan Hall Date: Mar 12, 2007 2:20 PM Subject: Weekly Update 3-12-07 To: Jens Palsberg Jens, This week I mostly worked on refining the USART implementation.  Since there are two USART devices on the microcontroller (USART0,USART1), I coded up a USART1 driver based on the USART0 driver.  Even though they are identical except for register accesses, my USART1 implementation would not work in the simulator.  All I can tell is there are no interrupts happening in the simulator, which is strange considering they are set in the code.   I'm not sure if this is a bug in the simulator or not.  Ben is currently helping me create a generic USART class which one can derive both the USART0 and USART1 implementations from.  Although this will make the end product cleaner, I'm doubtful it will solve the USART1 problem.  But who knows.  Ben and I haven't talked yet about what to do this week after this USART problem is fixed.  My guess is begin thinking about the radio. The thought I had this week was how to access registers in Virgil. There is a definite pain in having to look up every register you want to access in the ATMEL documentation.  It would be nice in virgil if you write a generic class for a device, that it can automatically generate code for the extended classes.  For example write a class called USART.  Then the methods access registers using say USART_DATAn.  Now you can extend this class and create USART0,USART1,... and at each place it sees a register with n in it, it replaces it with the respective number.  This idea could even be extended further to save implementation time.  Just a thought. - Ryan