By 'differently', I am referring to the code at /tools/tinyos/java/serial
----à here we can see two files, namely NativeSerial_win32 AND
NativeSerial_linux
For Windows (Cygwin) machines, I believe it gets the code for Baudrate from In
NativeSerial_win32 as below:
int getBaudRate()
{
int baud_rate = get_comm_state().BaudRate;
switch( baud_rate )
{
case CBR_110: return 110;
case CBR_300: return 300;
case CBR_600: return 600;
case CBR_1200: return 1200;
case CBR_2400: return 2400;
case CBR_4800: return 4800;
case CBR_9600: return 9600;
case CBR_14400: return 14400;
case CBR_19200: return 19200;
case CBR_38400: return 38400;
case CBR_56000: return 56000;
case CBR_57600: return 57600;
case CBR_115200: return 115200;
case CBR_128000: return 128000;
case CBR_256000: return 256000;
}
return baud_rate;
}
AND IN Linux machines, we get Baudrates from NativeSerial_linux file as below:
int baud_to_enum( int baud )
{
switch( baud )
{
case 0: return B0;
case 50: return B50;
case 75: return B75;
case 110: return B110;
case 134: return B134;
case 150: return B150;
case 200: return B200;
case 300: return B300;
case 600: return B600;
case 1200: return B1200;
case 1800: return B1800;
case 2400: return B2400;
case 4800: return B4800;
case 9600: return B9600;
case 19200: return B19200;
case 38400: return B38400;
case 57600: return B57600;
case 115200: return B115200;
case 230400: return B230400;
}
throw comm_port_error("baud_to_enum, bad baud rate");
}
int enum_to_baud( int baudenum )
{
switch( baudenum )
{
case B0: return 0;
case B50: return 50;
case B75: return 75;
case B110: return 110;
case B134: return 134;
case B150: return 150;
case B200: return 200;
case B300: return 300;
case B600: return 600;
case B1200: return 1200;
case B1800: return 1800;
case B2400: return 2400;
case B4800: return 4800;
case B9600: return 9600;
case B19200: return 19200;
case B38400: return 38400;
case B57600: return 57600;
case B115200: return 115200;
case B230400: return 230400;
}
throw comm_port_error("enum_to_baud, bad baud rate");
}
All my discussion is based on my belief that when we use Java tools like
"Listen, MsgReader, etc.", these files are used... if not then I am wrong but
if I am right, then we can see that after the baudrate of 115200bps, Linux
machines can have only 230400bps whereas Windows can have 128000 and 256000bps.
Secondly, my problem is that my platform has an atmel atmega128 processor, and
all the platforms having this processor can either have 19200 or 57600bps
BECAUSE in the UART code for atmega128 located at
/tos/chips/atm128/Atm128UartP.nc, it defines the following:
command error_t Init.init() {
if (PLATFORM_BAUDRATE == 19200UL)
m_byte_time = 200; // 1 TMicor ~= 2.12 us, one byte = 417us ~= 200
else if (PLATFORM_BAUDRATE == 57600UL)
m_byte_time = 68; // 1 TMicor ~= 2.12 us, one byte = 138us ~= 65
return SUCCESS;
}
So, I tried to add the code here and define the following:
else if (PLATFORM_BAUDRATE == 115200UL)
m_byte_time = 33; // 1 TMicor ~= 2.12 us, one byte = 69us ~= 33 -à 1
byte takes 69 us so 69/2.12 gives 33 (POINT ME IF I AM WRONG)
else if (PLATFORM_BAUDRATE == 230400UL)
m_byte_time = 17; // 1 TMicor ~= 2.12 us, one byte = 35us ~= 17
else if (PLATFORM_BAUDRATE == 256000UL)
m_byte_time = 15; // 1 TMicor ~= 2.12 us, one byte = 31us ~= 15
I think either I have a fault in m_byte_time value because for 57600bps
baudrate, it comes out 65, but a value of 68 is given in the basic code, I do
not know why??
THIS IS WHY I ASKED if the higher baudrates are handled differently in Linux
and Windows???
I need higher baudrate as the BaseStationw ill be receiving number of packets
per second, so it needs to send it out of serial faster otherwise there will be
a bottleneck.
I hope my question is more clearer now....
Cheers,
Varun Jain
From: Eric Decker [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 03, 2008 7:28 AM
To: Varun Jain
Subject: Re: [Tinyos-help] Serial Baudrate
What do you mean "differently for Linux and Windows"?
On Tue, Jul 1, 2008 at 7:37 PM, Varun Jain <[EMAIL PROTECTED]> wrote:
Hi,
Does anyone knows if Baudrate over 115200 bps is handed differently in
Tinyos-2.x for Linux and Windows(Cygwin). What are the maximum speeds I can set
up for them? I currently have Atmega-128 controller
Cheers,
Varun Jain
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
--
Eric B. Decker
Senior (over 50 :-) Researcher
Autonomous Systems Lab
Jack Baskin School of Engineering
UCSC
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help