Hi Carlos, Sorry. But trying to debug this kind of thing by looking at code and error messages such as provided is nigh near impossible.
You need to put in some debugging into the low level receiver (I would suggest modifing the PC side) so that you can capture the raw data coming over and being fed to the protocol engine. I've also just had a program that just spits out the received bytes so I can see what is coming over. On Tue, Sep 25, 2012 at 8:11 AM, Carlos Neto <[email protected]> wrote: > Dear all, > > I'm trying to make a nesC app, based on PppRouter and > TestSerial (configuration=PppSinkC, module=PppSinkP). > > The main objective is to: Send mig AM messages with a simple counter (in > future will be the routing table to the PC and commands to the BaseStation) > from mote to PC (Ubuntu OS). > > But I'm receiving an error. Please can Someone Help me? (below the > PppSinkC, PppSinkP and the output error) > > Thanks in advance. > Cheers > Carlos Neto > > Appends: > > > //////////////////////////////////////////////////////////////PppSinkC\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ > #include <iprouting.h> > #include "ppp.h" > #include "TestSerial.h" > > configuration PppSinkC { > } implementation { > components PppSinkP; > > // components MainC; > // PppSinkP.Boot -> MainC; > > //components LedsC as LedsC; > //PppSinkP.Leds -> LedsC; > > components PppDaemonC; > PppSinkP.PppControl -> PppDaemonC; > > components PppIpv6C; > PppDaemonC.PppProtocol[PppIpv6C.ControlProtocol] -> > PppIpv6C.PppControlProtocol; > PppDaemonC.PppProtocol[PppIpv6C.Protocol] -> PppIpv6C.PppProtocol; > PppIpv6C.Ppp -> PppDaemonC; > PppIpv6C.LowerLcpAutomaton -> PppDaemonC; > > PppSinkP.Ipv6LcpAutomaton -> PppIpv6C; > PppSinkP.PppIpv6 -> PppIpv6C; > PppSinkP.Ppp -> PppDaemonC; > > #if defined(PLATFORM_TELOSB) || defined(PLATFORM_EPIC) > components PlatformHdlcUartC as HdlcUartC; > #else > components DefaultHdlcUartC as HdlcUartC; > #endif > PppDaemonC.HdlcUart -> HdlcUartC; > PppDaemonC.UartControl -> HdlcUartC; > > // SDH : don't bother including the PppPrintfC by default > components PppPrintfC, PppC;; > PppPrintfC.Ppp -> PppDaemonC; > PppDaemonC.PppProtocol[PppPrintfC.Protocol] -> PppPrintfC; > PppPrintfC.Ppp -> PppC; > > components IPStackC, IPForwardingEngineP, IPPacketC; > IPForwardingEngineP.IPForward[ROUTE_IFACE_PPP] -> PppSinkP.IPForward; > PppSinkP.IPControl -> IPStackC; > PppSinkP.ForwardingTable -> IPStackC; > PppSinkP.IPPacket -> IPPacketC; > > #ifdef RPL_ROUTING > components RPLRoutingC, RplBorderRouterP; > PppSinkP.RootControl -> RPLRoutingC; > RplBorderRouterP.ForwardingEvents -> > IPStackC.ForwardingEvents[ROUTE_IFACE_PPP]; > RplBorderRouterP.IPPacket -> IPPacketC; > #endif > > #ifndef IN6_PREFIX > components Dhcp6ClientC; > PppSinkP.Dhcp6Info -> Dhcp6ClientC; > #endif > > components PppSinkP as App, LedsC, MainC; > App.Boot -> MainC.Boot; > App.Leds -> LedsC; > > components SerialActiveMessageC as AM; > App.IPControl -> AM; > App.Receive -> AM.Receive[AM_TEST_SERIAL_MSG]; > App.AMSend -> AM.AMSend[AM_TEST_SERIAL_MSG]; > App.Packet -> AM; > > components new TimerMilliC() as Timer; > App.MilliTimer -> Timer; > } > > > > //////////////////////////////////////////////////////////////PppSinkP\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ > #include <stdio.h> > #include <lib6lowpan/ip.h> > #include <lib6lowpan/nwbyte.h> > #include <lib6lowpan/ip_malloc.h> > #include <dhcp6.h> > #include "pppipv6.h" > #include "blip_printf.h" > #include "Timer.h" > #include "TestSerial.h" > > module PppSinkP { > provides { > interface IPForward; > } > uses { > interface Boot; > interface Leds; > interface SplitControl as IPControl; > interface SplitControl as PppControl; > interface LcpAutomaton as Ipv6LcpAutomaton; > interface PppIpv6; > interface Ppp; > interface ForwardingTable; > interface RootControl; > interface Dhcp6Info; > interface IPPacket; > interface Receive; > interface AMSend; > interface Timer<TMilli> as MilliTimer; > interface Packet; > } > } implementation { > message_t packet; > bool locked = FALSE; > uint16_t counter = 0; > > event void PppIpv6.linkUp() {} > event void PppIpv6.linkDown() {} > > event void Ipv6LcpAutomaton.transitionCompleted (LcpAutomatonState_e > state) { } > event void Ipv6LcpAutomaton.thisLayerUp () { } > event void Ipv6LcpAutomaton.thisLayerDown () { } > event void Ipv6LcpAutomaton.thisLayerStarted () { } > event void Ipv6LcpAutomaton.thisLayerFinished () { } > > event void PppControl.startDone (error_t error) { } > event void PppControl.stopDone (error_t error) { } > > event void IPControl.startDone (error_t error) { > struct in6_addr dhcp6_group; > > // add a route to the dhcp group on PPP, not the radio (which is the > default) > inet_pton6(DH6ADDR_ALLAGENT, &dhcp6_group); > call ForwardingTable.addRoute(dhcp6_group.s6_addr, 128, NULL, > ROUTE_IFACE_PPP); > > // add a default route through the PPP link > call ForwardingTable.addRoute(NULL, 0, NULL, ROUTE_IFACE_PPP); > > if (error == SUCCESS) { > call MilliTimer.startPeriodic(1000); > } > } > > event void IPControl.stopDone (error_t error) { } > > event void Boot.booted() { > error_t rc; > > #ifndef PRINTFUART_ENABLED > rc = call Ipv6LcpAutomaton.open(); > rc = call PppControl.start(); > #endif > #ifdef RPL_ROUTING > call RootControl.setRoot(); > #endif > #ifndef IN6_PREFIX > call Dhcp6Info.useUnicast(FALSE); > #endif > > call IPControl.start(); > } > > event error_t PppIpv6.receive(const uint8_t* data, unsigned int len) { > struct ip6_hdr *iph = (struct ip6_hdr *)data; > void *payload = (iph + 1); > call Leds.led0Toggle(); > signal IPForward.recv(iph, payload, NULL); > return SUCCESS; > } > > command error_t IPForward.send(struct in6_addr *next_hop, struct > ip6_packet *msg, void *data) { > size_t len = iov_len(msg->ip6_data) + sizeof(struct ip6_hdr); > error_t rc; > frame_key_t key; > const uint8_t* fpe; > uint8_t* fp; > > if (!call PppIpv6.linkIsUp()) > return EOFF; > > // get an output frame > fp = call Ppp.getOutputFrame(PppProtocol_Ipv6, &fpe, FALSE, &key); > if ((! fp) || ((fpe - fp) < len)) { > if (fp) { > call Ppp.releaseOutputFrame(key); > } > call Leds.led2Toggle(); > return ENOMEM; > } > > // copy the header and body into the frame > memcpy(fp, &msg->ip6_hdr, sizeof(struct ip6_hdr)); > iov_read(msg->ip6_data, 0, len, fp + sizeof(struct ip6_hdr)); > rc = call Ppp.fixOutputFrameLength(key, fp + len); > if (SUCCESS == rc) { > rc = call Ppp.sendOutputFrame(key); > } > > call Leds.led1Toggle(); > > return rc; > } > > event void Ppp.outputFrameTransmitted (frame_key_t key, error_t err) { } > > event void MilliTimer.fired() { > counter++; > if (locked) { > return; > } > else { > test_serial_msg_t* rcm = (test_serial_msg_t*)call > Packet.getPayload(&packet, sizeof(test_serial_msg_t)); > if (rcm == NULL) {return;} > if (call Packet.maxPayloadLength() < sizeof(test_serial_msg_t)) { > return; > } > > rcm->counter = counter; > if (call AMSend.send(AM_BROADCAST_ADDR, &packet, > sizeof(test_serial_msg_t)) == SUCCESS) { > locked = TRUE; > } > } > } > > event message_t* Receive.receive(message_t* bufPtr, void* payload, > uint8_t len) { > if (len != sizeof(test_serial_msg_t)) { > return bufPtr; > } > else { > test_serial_msg_t* rcm = (test_serial_msg_t*)payload; > if (rcm->counter & 0x1) { > call Leds.led0On(); > } > else { > call Leds.led0Off(); > } > if (rcm->counter & 0x2) { > call Leds.led1On(); > } > else { > call Leds.led1Off(); > } > if (rcm->counter & 0x4) { > call Leds.led2On(); > } > else { > call Leds.led2Off(); > } > return bufPtr; > } > } > > event void AMSend.sendDone(message_t* bufPtr, error_t error) { > if (&packet == bufPtr) { > locked = FALSE; > } > } > } > > > > > //////////////////////////////////////////////////////////////Output\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ > root@ubuntu:/opt/tinyos-2.1.2/apps/PppSink# java net.tinyos.tools.Listen > -comm serial@/dev/ttyUSB0:telosb > serial@/dev/ttyUSB0:115200: resynchronising > serial@/dev/ttyUSB0:115200: bad packet > serial@/dev/ttyUSB0:115200: bad packet > serial@/dev/ttyUSB0:115200: bad packet > serial@/dev/ttyUSB0:115200: bad packet > serial@/dev/ttyUSB0:115200: bad packet > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > -- Eric B. Decker Senior (over 50 :-) Researcher
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
