[Tinyos-help] TinyOs 2.0.2 Dispatcher Implementation Problem
Hi Folks, I am trying to write a piece of code in which I need a remote control to broadcast several commands to a bunch of nodes and each of them has to handle this message to figure out if there is any action for it. Assuming the remote control send the command START_EMISSION asking to the node with id x to send SAMPLES times of an hello msg. This is the portion of code I wrote for the node x. It is supposed to be a dispatcher to decide which is the proper action associated to a given command. /* When a msg is received its payload is copied in a local global structure and the dispatcher is called */ event message_t* AMProtoReceive.receive(message_t* msg, void* payload, uint8_t len) { Protocol_Msg *btrpkt = (Protocol_Msg*)(call AMProtoPacket.getPayload(msg, NULL)); atomic { P_payload.protocol_id = btrpkt-protocol_id; P_payload.parameter_1 = btrpkt-parameter_1; P_payload.parameter_2 = btrpkt-parameter_2; } post protocol_msg_handler(); return SUCCESS; } /* The Dispacher realizes the command START_EMISSION has been received and the startEmission task is posted */ task void protocol_msg_handler(){ switch(P_payload.protocol_id) { case START_EMISSION: { if (P_payload.parameter_1 == TOS_NODE_ID) { train = P_payload.parameter_2; sample=SAMPLES; call Leds.led1On(); post startEmission(); } break; } case SEND_DATA: { if (P_payload.parameter_1 == TOS_NODE_ID) post sendData(); break; } } } /* This task simply start a periodic time where TIMER_PERIOD_EMISSION is the the period at which the hello msg has to be sent */ task void startEmission() { call Timer0.startPeriodic(TIMER_PERIOD_EMISSION); } /* Each step the period is expired the emissionRadio is posted */ event void Timer0.fired() { call Leds.led0Toggle(); post emissionRadio(); } /* The hello msg is built and then it is sent */ task void emissionRadio(){ if (sample0) { DTOA_Msg *btrpkt = (DTOA_Msg*)(call AMDTOAPacket.getPayload(pktDTOA, NULL)); btrpkt-node_id=sample; call AMDTOASend.send(AM_BROADCAST_ADDR, pktDTOA, sizeof(DTOA_Msg)); } else{ call Timer0.stop(); } } /* After the confermation of the send of the msg the number of samples is decreased */ event void AMProtoSend.sendDone(message_t* msg, error_t error) { atomic sample--; } The problem is that after the first hello msg is sent the node stucks and I don't understand why. Can anybody help me? Thank you, Andrea P.S.: In attachment the full source code if you are interested. - This email was sent using SquirrelMail. https://email.dia.uniroma3.it Web Site: http://www.squirrelmail.org/ NodeAppC.nc Description: Cdf file NodeC.nc Description: Cdf file #ifndef PARAMETERS_H #define PARAMETERS_H /* ID nodes */ enum { BASE_STATION=0, REMOTE_CONTROL=254 }; /* Timers */ enum { TIMER_START=1000, /* Microsecond */ TIMER_SOUND=100, /* Milli */ TIMER_PERIOD_EMISSION=2000 /* Milli */ }; /* Port for Packets */ enum { AM_PROTOCOL= 5, /* Port used for both commands and notification msgs*/ AM_DTOA = 6, /* Port used for dtoa msgs*/ AM_DATA= 7 /* Port used for notification msgs*/ }; /* Protocol Ids */ enum { START_EMISSION = 1, /* To notify to start of an emission */ END_EMISSION = 2, /* To notify to end of an emission */ SEND_DATA = 3, /* To notify to send data */ DATA_SENT=4 /* To notify data has been sent */ }; /* Configuration Parameters */ enum { UNKNOWNS = 3, ANCHORS = 0, SAMPLES = 6, TRAINS = 1, ITERATIONS = 2 }; /* To define the structure of a msg*/ typedef nx_struct DTOA_Msg { /* Note that the type nx_uint16_t is introduced. This type differs from the C type int16_t as the byte ordering is handled internally. */ nx_uint16_t node_id; } DTOA_Msg; typedef nx_struct Data_Msg { /* Note that the type nx_uint16_t is introduced. This type differs from the C type int16_t as the byte ordering is handled internally. */ nx_uint16_t receiver; nx_uint32_t samples[SAMPLES]; nx_uint32_t emitter; nx_uint32_t iter; } Data_Msg; typedef nx_struct Protocol_Msg { /* Note that the type nx_uint16_t is introduced. This type differs from the C type int16_t as the byte ordering is handled internally. */ nx_uint8_t protocol_id; nx_uint8_t parameter_1; nx_uint8_t parameter_2; } Protocol_Msg; #endif___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
[Tinyos-help] TinyOs 2.0.2 Dispatcher Implementation Problem
Hi Folks, I am trying to write a piece of code in which I need a remote control to broadcast several commands to a bunch of nodes and each of them has to handle this message to figure out if there is any action for it. Assuming the remote control send the command START_EMISSION asking to the node with id x to send SAMPLES times of an hello msg. This is the portion of code I wrote for the node x. It is supposed to be a dispatcher to decide which is the proper action associated to a given command. /* When a msg is received its payload is copied in a local global structure and the dispatcher is called */ event message_t* AMProtoReceive.receive(message_t* msg, void* payload, uint8_t len) { Protocol_Msg *btrpkt = (Protocol_Msg*)(call AMProtoPacket.getPayload(msg, NULL)); atomic { P_payload.protocol_id = btrpkt-protocol_id; P_payload.parameter_1 = btrpkt-parameter_1; P_payload.parameter_2 = btrpkt-parameter_2; } post protocol_msg_handler(); return SUCCESS; } /* The Dispacher realizes the command START_EMISSION has been received and the startEmission task is posted */ task void protocol_msg_handler(){ switch(P_payload.protocol_id) { case START_EMISSION: { if (P_payload.parameter_1 == TOS_NODE_ID) { train = P_payload.parameter_2; sample=SAMPLES; call Leds.led1On(); post startEmission(); } break; } case SEND_DATA: { if (P_payload.parameter_1 == TOS_NODE_ID) post sendData(); break; } } } /* This task simply start a periodic time where TIMER_PERIOD_EMISSION is the the period at which the hello msg has to be sent */ task void startEmission() { call Timer0.startPeriodic(TIMER_PERIOD_EMISSION); } /* Each step the period is expired the emissionRadio is posted */ event void Timer0.fired() { call Leds.led0Toggle(); post emissionRadio(); } /* The hello msg is built and then it is sent */ task void emissionRadio(){ if (sample0) { DTOA_Msg *btrpkt = (DTOA_Msg*)(call AMDTOAPacket.getPayload(pktDTOA, NULL)); btrpkt-node_id=sample; call AMDTOASend.send(AM_BROADCAST_ADDR, pktDTOA, sizeof(DTOA_Msg)); } else{ call Timer0.stop(); } } /* After the confermation of the send of the msg the number of samples is decreased */ event void AMProtoSend.sendDone(message_t* msg, error_t error) { atomic sample--; } The problem is that after the first hello msg is sent the node stucks and I don't understand why. Can anybody help me? Thank you, Andrea P.S.: In attachment the full source code for a node. The remote control is not provided as it does not do anything special just send the command. - This email was sent using SquirrelMail. https://email.dia.uniroma3.it Web Site: http://www.squirrelmail.org/#ifndef PARAMETERS_H #define PARAMETERS_H /* ID nodes */ enum { BASE_STATION=0, REMOTE_CONTROL=254 }; /* Timers */ enum { TIMER_START=1000, /* Microsecond */ TIMER_SOUND=100, /* Milli */ TIMER_PERIOD_EMISSION=2000 /* Milli */ }; /* Port for Packets */ enum { AM_PROTOCOL= 5, /* Port used for both commands and notification msgs*/ AM_DTOA = 6, /* Port used for dtoa msgs*/ AM_DATA= 7 /* Port used for notification msgs*/ }; /* Protocol Ids */ enum { START_EMISSION = 1, /* To notify to start of an emission */ END_EMISSION = 2, /* To notify to end of an emission */ SEND_DATA = 3, /* To notify to send data */ DATA_SENT=4 /* To notify data has been sent */ }; /* Configuration Parameters */ enum { UNKNOWNS = 3, ANCHORS = 0, SAMPLES = 6, TRAINS = 1, ITERATIONS = 2 }; /* To define the structure of a msg*/ typedef nx_struct DTOA_Msg { /* Note that the type nx_uint16_t is introduced. This type differs from the C type int16_t as the byte ordering is handled internally. */ nx_uint16_t node_id; } DTOA_Msg; typedef nx_struct Data_Msg { /* Note that the type nx_uint16_t is introduced. This type differs from the C type int16_t as the byte ordering is handled internally. */ nx_uint16_t receiver; nx_uint32_t samples[SAMPLES]; nx_uint32_t emitter; nx_uint32_t iter; } Data_Msg; typedef nx_struct Protocol_Msg { /* Note that the type nx_uint16_t is introduced. This type differs from the C type int16_t as the byte ordering is handled internally. */ nx_uint8_t protocol_id; nx_uint8_t parameter_1; nx_uint8_t parameter_2; } Protocol_Msg; #endif NodeC.nc Description: Cdf file NodeAppC.nc Description: Cdf file ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
[Tinyos-help] JTAG
HI All, I am wondering if anyone has tested the JTAG in tmote sky! I would like to know if there is any tools for testing and debugging some modules like MSP..and cc2420? Is it possible to measure the power consumption via the JTAG? I would really appreciate any help in this topic. Best mona ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [Tinyos-help] JTAG
hi i used the JTAG interface with tmotes and the eclipse framework. here you can find some description on this: http://www.btnode.ethz.ch/Projects/TinyOS2 I don't think its possible to measure power consumption with JTAG. roman Mona.baher wrote: HI All, I am wondering if anyone has tested the JTAG in tmote sky! I would like to know if there is any tools for testing and debugging some modules like MSP..and cc2420? Is it possible to measure the power consumption via the JTAG? I would really appreciate any help in this topic. Best mona ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [Tinyos-help] MSP430 get clock
Steve McKown ha scritto: On Tuesday 11 September 2007 12:27:31 pm Leonardo wrote: Steve McKown ha scritto: On Tuesday 11 September 2007 08:48:49 am Leonardo wrote: Steve McKown ha scritto: On Tuesday 11 September 2007 08:25:14 am Leonardo wrote: Hy guy, I need to help. I want to capture the clock of my telosb. I know that i have to use MSP430 but how? how can I get the clock with MSP430? Two questions: which clock do you want to get, and how do you want to get it? For the former, the msp430 maintains a number of clocks, for example, MCLK, SMCLK, ACLK. For the latter, are you wanting to expose the clock to a digital output pin for use by a bit of add-on hardware, or do you want to expose it to a software component to trigger some action? Steve i need to get the clock because i have to sincronized my wireless network. i have to get the clock and set the clock on my telosb. i didn't know that there are many clock in telosb, but I need to only one. Thanks for help me You probably want to look at the msp430's Timer B, which is wired in TinyOS to the 32KHz crystal. This clock runs even in sleep mode, which is probably what you need to deal with timed radio events. The standard TinyOS TimerTMilli is a software timer attached to Timer B. There may be a 32KHz resolution Timerxxx; I don't recall off the top of my head. So I presume that you'll pass around some kind of timebase or offset in radio packets between nodes, when the nodes can then use to determine which next to transmit or receive. You probably can't manage more than a gross coordination without digging into the radio's software stack. If you can, try to use the LPL (low power wireless) mode of the cc2420 radio stack. It's already there and works pretty well. If you need something else, check the TEPs; there's one that covers the software layers in the new stack, and you could create your own layer to implement a new timing policy if that's what you need. Cheers, Steve Thanks for you help Steve, but I have another problem and i think my english don't help me :D I need to get and set the clock of my process for sicronized my telos. the problem is that i don't know the way to get and set the clock Do you understand me now? Sorry for my english In my project i have to send the clock of master on network in the beacon message. The slave get the clock and set its clock. in this way they are sincronized because in the beacon vector there is the correcly sequence to transmit and receive the data message. and in this way each node rise up at the right moment. I don't think you need synchronized clocks per se, since you can use the the beacon itself to find a common point in time (t0) between beacon sender and receivers. Then, to sechedule future events, one schedules t0 + deltaT. There's some timing feedback in the radio stack to help find t0. So all you need is a clock source with suitable granularity and precision, and a way to manage the latency between desired and actual event timings. If you are implementing something like the beaconed protocol that's part of 802.15.4, I *think* you can get by with a crystal-derived 32KHz clock, as available on the TelosB platforms. Even though the new cc2420 radio stack is modular, creating a new layer to implement a beacon-timed network protocol is going to be a big job. To get back to your original question, I'd expect you might use an Msp430Timer32khzC component for scheduling future timed events. You'll need a good understanding of the interrupts that can occur in the system which could cause your radio events to be deferred for a period. Not to mention getting to know the radio stack itself very well. If, on the other hand, you are creating something with far looser timing requirements, say a 100ms or larger granularity, then maybe you can get by with using TimerTMilli to set future events and using ActiveMessageC's SplitControl interface to initiate future communications at the right time. Steve Thank Steve, I understand all. But I have another question now: in my code now write in this way: BeaconN.nc .. uses Interface MSP430Timer; ... and in this file: BeaconC.nc: components new MSP430Timer32khzC() as MSP430Timer; BeaconM.MSP430Timer - MSP430Timer; in this way do it caputer the clock that i want? when i write: now= call MSP430Timer.get(); in now is there my clock? ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
[Tinyos-help] Moteiv's Delta on MicaZ
Does Moteiv's Delta application provided in Boomerang work on MicaZ motes? Thank you for your attention! Tim ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [tinyos-help] clarifications about serial communication
Steve, Your response was of great help. Let me know if you can provide some pointers on how this could be done using the BSL or share the part of your code where the mote is reset if 3 write failed events trigger consecutively. Thanks once again Mayur On 9/10/07, Steve McKown [EMAIL PROTECTED] wrote: On Sunday 02 September 2007 12:59:44 pm Mayur Maheshwari wrote: Hi Romain This is regarding the problem which you faced while sending the data to the BaseStation from SerialForwarder(SF) when it continuously gives the Write Failed event. Let me know if you got any success with that. I did few things and later found that the problem lies in the mote: 1. I stopped the SF, removed the modules controlling my mote from the linux kernel i.e. usbserial and ftdi-sio while the mote is still plugged in. I restarted all the components and the sitaution was the same. However, the mote was getting continous power from the USB all the time. 2. While the SF was running and Write Failed event coming up on every attempt to send data, I pushed the reset button on the telosB. This was a mild success as the SF app was able to send the data after this. Right now I am thinking in a direction that the mote should stop and restart the radio and the UART if such an event occurs. This is not a good technique but does help in automating the reset scenario. I also see this on our own msp430-based mote design. I tend to suspect clock drift of the DCO taking the baud rate out of spec. I've seen similar behavior on read events as well, and in all cases so far, resetting the mote corrects the problem for some period of time. To work around this in the mean time, our base station code resets the attached mote (using BSL) if we see 3 of these communications errors in a row. If this is the issue, then installing a crystal @ XT2 would solve the problem. We haven't had the time yet to try this out, but I'll report back if/when we ever do this. -- Mayur Maheshwari([EMAIL PROTECTED]) Karmanye Vadhikaraste Ma Phaleshu Kadachana, Ma Karma Phala Hetur Bhurmatey Sangostva Akarmani ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [Tinyos-help] TinyOs 2.0.2 Dispatcher Implementation Problem
On Sep 11, 2007, at 11:48 PM, [EMAIL PROTECTED] wrote: event message_t* AMProtoReceive.receive(message_t* msg, void* payload, uint8_t len) { Protocol_Msg *btrpkt = (Protocol_Msg*)(call AMProtoPacket.getPayload(msg, NULL)); atomic { P_payload.protocol_id = btrpkt-protocol_id; P_payload.parameter_1 = btrpkt-parameter_1; P_payload.parameter_2 = btrpkt-parameter_2; } post protocol_msg_handler(); return SUCCESS; } The problem is that after the first hello msg is sent the node stucks and I don't understand why. Can anybody help me? SUCCESS is not a pointer to a message_t. You're passing a NULL pointer, and so the next packet that's received blows away control registers. Your compilation has a warning that says you're casting improperly. Phil ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
[Tinyos-help] question about SimpleCmd Bcast application
Hello, professors of berkeley Im Diego Maldonado student of Electronic Enginneer from Colombia, Universidad Industrial de Santander ( UIS). Currently i'm developing my bachelor thesis in wireless sensor networks subject by working with telos B and tmote Sky devices. I have a doubt regarding to SimpleCmd Application when it is set up with Bcast option. i'm trying to set a latency testbed where there is a mote conected to my laptop sending led_on and led_off commands to 7 receivers telos b y tmote sky. six of them are programmed with bcast option and the last one with simplecmd (end device), so in theory, i have 7 hops before reach the final one. My question is this: If six of them are programmed to make bcast ..how can i know about the order of forwarding packets? I mean, as they are all under the same cordinator coverage range , how can I kwow if a command sended from the cordinator is being received for 2 or more bcast motes at the same time, which would be a problem because I want the data to hop from the first Bcast receiver to the second and then to 3rd one and so on, until reaching the final one...so i can register the latenciy caused by going through several hops. I hop you can understand my non-perfect english and I appreciate if you can give me a hand with this I only have a week to deadline. thank you very much friends from Berkeley Diego Armando Maldonado. -- Open WebMail Project (http://openwebmail.org) ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [Tinyos-help] question about SimpleCmd Bcast application
If you want to measure latency over seven hops, don't send a broadcast message, send a message addressed to a specific node i.e. always send to (TOS_NODE_ID + 1), then program each node with successive ids and measure the time it takes between sending on the first node in the chain and being received at the end. Kevin On 9/10/07, Diego Maldonado [EMAIL PROTECTED] wrote: Hello, professors of berkeley Im Diego Maldonado student of Electronic Enginneer from Colombia, Universidad Industrial de Santander ( UIS). Currently i'm developing my bachelor thesis in wireless sensor networks subject by working with telos B and tmote Sky devices. I have a doubt regarding to SimpleCmd Application when it is set up with Bcast option. i'm trying to set a latency testbed where there is a mote conected to my laptop sending led_on and led_off commands to 7 receivers telos b y tmote sky. six of them are programmed with bcast option and the last one with simplecmd (end device), so in theory, i have 7 hops before reach the final one. My question is this: If six of them are programmed to make bcast ..how can i know about the order of forwarding packets? I mean, as they are all under the same cordinator coverage range , how can I kwow if a command sended from the cordinator is being received for 2 or more bcast motes at the same time, which would be a problem because I want the data to hop from the first Bcast receiver to the second and then to 3rd one and so on, until reaching the final one...so i can register the latenciy caused by going through several hops. I hop you can understand my non-perfect english and I appreciate if you can give me a hand with this I only have a week to deadline. thank you very much friends from Berkeley Diego Armando Maldonado. -- Open WebMail Project (http://openwebmail.org) ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help -- ~Kevin ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
RE: [Tinyos-help] Moteiv's Delta on MicaZ
Hi Tim, If you are looking for mesh routing stack for MICAz, you might want to consider XMesh from Crossbow that is distributed with MoteView and MoteWorks. http://www.xbow.com/Support/wSoftwareDownloads.aspx More details are available in the XMesh user's manual below. http://www.xbow.com/Support/Support_pdf_files/XMesh_Users_Manual.pdf Regards, Giri From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Timothy Strongton Sent: Wednesday, September 12, 2007 6:06 AM To: Tinyos-help@Millennium.Berkeley.EDU Subject: [Tinyos-help] Moteiv's Delta on MicaZ Does Moteiv's Delta application provided in Boomerang work on MicaZ motes? Thank you for your attention! Tim ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [Tinyos-help] Moteiv's Delta on MicaZ
The short answer is no. Delta has been optimized for Moteiv's Tmote Sky and Tmote Invent modules. Since Boomerang is open source, you are welcome to use Delta and try to port it to other platforms as necessary, but the only platforms it will work with out of the box are Tmote Sky and Tmote Invent. -Joe On 9/12/07, Timothy Strongton [EMAIL PROTECTED] wrote: Does Moteiv's Delta application provided in Boomerang work on MicaZ motes? Thank you for your attention! Tim ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
Re: [tinyos-help] clarifications about serial communication
On Wednesday 12 September 2007 09:32:00 am Mayur Maheshwari wrote: Steve, Your response was of great help. Let me know if you can provide some pointers on how this could be done using the BSL or share the part of your code where the mote is reset if 3 write failed events trigger consecutively. You can grab the logic from the tos-bsl program that comes in the tinyos-tools package and installs into /usr/bin. I've attached a C snippet that I used. Use the rest_gwbs() function. It's a poor substutue for solving the real problem, but is an OK stopgap for development or testing, anyway... Cheers, Steve Thanks once again Mayur On 9/10/07, Steve McKown [EMAIL PROTECTED] wrote: On Sunday 02 September 2007 12:59:44 pm Mayur Maheshwari wrote: Hi Romain This is regarding the problem which you faced while sending the data to the BaseStation from SerialForwarder(SF) when it continuously gives the Write Failed event. Let me know if you got any success with that. I did few things and later found that the problem lies in the mote: 1. I stopped the SF, removed the modules controlling my mote from the linux kernel i.e. usbserial and ftdi-sio while the mote is still plugged in. I restarted all the components and the sitaution was the same. However, the mote was getting continous power from the USB all the time. 2. While the SF was running and Write Failed event coming up on every attempt to send data, I pushed the reset button on the telosB. This was a mild success as the SF app was able to send the data after this. Right now I am thinking in a direction that the mote should stop and restart the radio and the UART if such an event occurs. This is not a good technique but does help in automating the reset scenario. I also see this on our own msp430-based mote design. I tend to suspect clock drift of the DCO taking the baud rate out of spec. I've seen similar behavior on read events as well, and in all cases so far, resetting the mote corrects the problem for some period of time. To work around this in the mean time, our base station code resets the attached mote (using BSL) if we see 3 of these communications errors in a row. If this is the issue, then installing a crystal @ XT2 would solve the problem. We haven't had the time yet to try this out, but I'll report back if/when we ever do this. void set_scl(int fd, int level) { unsigned int rts = TIOCM_RTS; if (level) ioctl(fd, TIOCMBIC, rts); else ioctl(fd, TIOCMBIS, rts); //usleep(100); } void set_sda(int fd, int level) { unsigned int dtr = TIOCM_DTR; if (level) ioctl(fd, TIOCMBIC, dtr); else ioctl(fd, TIOCMBIS, dtr); //usleep(100); } void i2c_start(int fd) { set_sda(fd, 1); set_scl(fd, 1); set_sda(fd, 0); } void i2c_stop(int fd) { set_sda(fd, 0); set_scl(fd, 1); set_sda(fd, 1); } void i2c_wbit(int fd, int bit) { set_scl(fd, 0); set_sda(fd, bit); usleep(2); set_scl(fd, 1); usleep(2); set_scl(fd, 0); } void i2c_wbyte(int fd, int byte) { i2c_wbit(fd, byte 0x80); i2c_wbit(fd, byte 0x40); i2c_wbit(fd, byte 0x20); i2c_wbit(fd, byte 0x10); i2c_wbit(fd, byte 0x08); i2c_wbit(fd, byte 0x04); i2c_wbit(fd, byte 0x02); i2c_wbit(fd, byte 0x01); i2c_wbit(fd, 0 ); /* acknowledge */ } void i2c_wcmd(int fd, int addr, int cmdbyte) { i2c_start(fd); i2c_wbyte(fd, 0x90 | (addr 1)); i2c_wbyte(fd, cmdbyte); i2c_stop(fd); } void tmote_reset(int fd) { i2c_wcmd(fd, 0, 3); i2c_wcmd(fd, 0, 2); i2c_wcmd(fd, 0, 0); usleep(25); /* give MSP430's oscillator time to stabilize */ } void reset_gwbs(serial_source src) { /* This is currently hardcoded to support the telos mote. The reset * process is different for different motes. See the docs for tos-bsl. * for more information. */ tmote_reset(serial_source_fd(src)); } ___ Tinyos-help mailing list Tinyos-help@Millennium.Berkeley.EDU https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help