Hey
Thanks for the quick reply.
The raw data is from MicaZ running a program written in MoteWorks. It is
based on TinyOS-1.x I think.
I couldn't install TinyOS 2.1.1 on my Ubuntu OS, and hence I'm stuck
programming it on MoteWorks.
The code i used to get the raw data is attached. It's based on
arduino-serial.c that i found online.
This was the only option i had, as i needed a program to read and write to
USB without the java packages coming in, as it does in SerialForwarder.
Also, My mote doesn't react when i send back the same string through the
USB. And i'm clueless as to why. Can you help??
And I will go through the TEP, thank you.
Always Yours
Tejovanth
Tj n Spook
On Wed, Jul 13, 2011 at 1:28 PM, Romain Bornet <[email protected]>wrote:
> Hi,
>
> Have a look at TEP 113: Serial Communication
> In section 3.6 Packet Format the layout of the bytes is explained.
>
> What you see is the "raw" frame at the lowest level of the serial
> stack. It is encoded in a HDLC-like way.
> In your case the frame 7e 42 7d 5e 00 00 7d 5d 04 01 00 96 00 1c 32 7e
> can be split into:
>
> -- HDLC header
> 7e HDLC framing byte (start of frame)
> 42 Protocol byte (0x42 = 66 -> )
> 7d HDLC escape character because next byte should be '7e'
> 5e Sequence number
>
> -- Payload = Active Message
> 00 00 7d 5d 04 01 00 96 00 (here again there is an HDLC escape
> character 7d....)
>
> Payload "HDLC decoded" = 00 00 7d 04 01 00 96 00
> According to the serial_header_t in Serial.h of the latest TinyOS this
> would correspond to:
> 00 00 dest
> 7d 04 source
> 01 length
> 00 AM group
> 96 AM Type
> 00 1 byte Data
>
> -- HDLC footer
> 1c 16 bits CRC high byte
> 32 16 bits CRC low byte
> 7e HDLC framing byte (end of frame)
>
> The Payload seems strange to me... Which version of TinyOS are you
> using ? How do you test ? With a standard application or one you wrote
> yourself ?
>
> I suggest you to have a look at the TEPs mentioned above and in
> sources found in your TinyOS source tree under lib/serial .
>
> Regards
> Romain
>
> On Wed, Jul 13, 2011 at 7:32 AM, TJ <[email protected]> wrote:
> > Hey.
> >
> > I get the following line in hex (similar to this) when i receive a packet
> > from the MicaZ mote on Ubuntu.
> > 7e 42 7d 5e 00 00 7d 5d 04 01 00 96 00 1c 32 7e
> >
> > I'm not really sure on what the all the numbers are, except that the one
> in
> > red is the node id, and one in green is a count. This I know because of
> the
> > structure i put in.
> >
> > If my program sends the same line from the PC to the mote, will the mote
> > understand it??
> >
> > Always Yours
> > Tejovanth
> > Tj n Spook
> >
> > _______________________________________________
> > Tinyos-help mailing list
> > [email protected]
> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> >
>
#include <stdio.h> // Standard input/output definitions
#include <string.h> // String function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitions
#include <inttypes.h>
#include <iostream>
using namespace std;
typedef struct
{
int a;
char str[20];
float data;
}__attribute__((packed)) Packet;
/* /dev/ttyUSB0 */
#define u1 "/dev/ttyUSB0"
#define LENGTH 16
Packet *pack;
int main()
{
uint8_t a=10;
cout<<sizeof(Packet)<<"\n\n";
uint8_t chin[30];
int c=0;
int n=0; //start
int mainfd=open(u1, O_WRONLY | O_NOCTTY | O_NDELAY);
if (mainfd == -1){
printf("File not found %s\n\n\n%d", u1,n);
return 1;
}
struct termios options, oldt;
tcgetattr( STDIN_FILENO, &oldt ); //Previous settings
fcntl(mainfd, F_SETFL, FNDELAY); // Configure port reading
// Get the current options for the port
tcgetattr(mainfd, &options);
cfsetispeed(&options, B57600); // Set the baud rates to 1200
cfsetospeed(&options, B57600);
options.c_cflag |= (CLOCAL | CREAD); // Enable the receiver and set local mode
options.c_cflag &= ~PARENB; // Mask the character size to 8 bits, no parity
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8; // Select 8 data bitsev
options.c_cflag &= ~CRTSCTS; // Disable hardware flow control
options.c_lflag &= ~(ICANON | ECHO | ISIG); // Enable data to be processed as raw input
tcsetattr(mainfd, TCSANOW, &options); // Set the new options for the port
long count=0;
while(1)
{
// //writing
// mainfd=open(u1, O_WRONLY | O_NOCTTY | O_NDELAY);
// n+= write(mainfd, &a, 1);
//reading
mainfd=open(u1, O_RDONLY | O_NOCTTY | O_NDELAY);
usleep(100);
read(mainfd, &chin, LENGTH+5);
int a = (int)(chin[9] );
int b = (int)(chin[11]);
for(int i=0;i<LENGTH;i++)
printf("%x ",(int)chin[i]);
printf("\n");
usleep(7500);
cout<<count++<<": ";
}
tcsetattr(STDIN_FILENO, TCSANOW, &oldt); //Reset terminal
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help