CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RTL8019 data receive error

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
janet



Joined: 17 Feb 2004
Posts: 23

View user's profile Send private message

RTL8019 data receive error
PostPosted: Tue Feb 17, 2004 3:34 am     Reply with quote

Hi,

I am using RTL8019 driver bundled with CCS compiler to receive a arp request. However, the data received after line 2 is not in correct format.

line 2 should start with 0x08 00 (IP), instead of 0x40 00. The packet length is always 0x3ffc :(

I wish somebody can point me out where i did mistake. thank you.

#include "rcv.h"
#include "rtl8019.c"

BYTE buffer[500];
int16 rx_len;
int i, j , k;

int t;
void main() {

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);

nic_init();
i = 0;
j = k = 0;
t = 0;
while(TRUE) {

if (nic_begin_packet_rx() && t == 0) {
i++;
printf("PACKET %4U : length : %4LX \n\r\n\r", i, nic_begin_packet_rx());

for (j=0; j < 0x10; j++) {
for (k= 0; k < 16; k++) {
printf(" %2X ", buffer[j * 16 + k]);
}
printf("\n\r");
}
nic_packet_get_data(buffer, rx_len);
nic_end_packet_rx();

t++;
}

}
}

Result:

PACKET 1 : length : 3FFC

FF FF FF FF FF FF 00 0B CD 55 CB 28 08 06 00 01
40 00 02 61 04 08 80 00 00 24 86 01 10 00 80 40
00 00 40 02 80 41 11 04 00 00 00 00 10 02 85 08
00 00 A0 04 08 20 80 00 00 00 32 00 00 00 80 03
02 A7 40 40 80 45 00 02 00 00 02 00 00 00 01 00
1C 00 00 80 20 0A 01 00 02 08 00 20 00 04 40 00
02 00 08 00 00 0A 42 00 10 9A 00 01 00 00 10 40
80 00 08 80 40 00 00 00 01 20 00 84 04 00 89 80
10 01 08 00 08 20 20 00 14 00 00 04 00 48 00 00
24 00 44 08 01 08 11 04 00 40 80 02 02 40 C0 00
4B 40 10 00 00 90 00 00 08 20 80 00 20 02 00 AE
80 08 02 20 04 00 00 01 00 20 20 61 01 00 00 00
04 30 00 00 03 00 00 02 00 44 00 40 A0 90 00 00
00 08 04 80 00 14 00 00 00 D0 20 01 08 20 10 30
80 A0 00 04 01 31 00 40 00 20 00 82 00 00 A0 00
00 01 80 20 0C 00 24 20 00 82 00 81 01 00 00 00
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Feb 17, 2004 4:33 am     Reply with quote

You're right the packet is broken for the ARP type 0806 subtype 0001 the proto should be 0800.....I would use a packet sniffer ( I use Ethereal it's free on the web) on a PC that is connected to the net with your PIC app.
This way you can see if the original ethernet packet is corrupted (least likely)or the corruption occurs within the RTL8019 PIC code(more likely). It looks like you buffer is not getting posted beyond the first 16 bytes or the read addressing only works for j=0. The j*16+k may have issues since the buffer size is greater than 255 . Both j and k are 8 bit so the compiler may truncate to an 8 bit result. Take a look at the lst file to see if the compiler understands that the j*16+k needs to be 16 bits. Cast it if you're not convinced its done right.
Other possible issues...
The nic_packet_get_data(buffer, rx_len);
call to get the rx buffer from the ethernet controller is out of the print loop
and len does not appear to be assigned
janet



Joined: 17 Feb 2004
Posts: 23

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 5:50 am     Reply with quote

Thanks doug!

I have enclosed a screen shot of the packet sniffer (i use ethereal as well)
at
http://www.electro-tech-online.com/viewtopic.php?t=6845


Yhe ARP packet i released is only 42 bytes, But nic_begin_packet_rx()
returns 0x3ffc!

Could you tell me where can i get a RTL8019 driver, apart from this one? Microchip offers one, but it was written in C18 and Hitech format.
janet



Joined: 17 Feb 2004
Posts: 23

View user's profile Send private message

PostPosted: Tue Feb 17, 2004 9:47 pm     Reply with quote

I got it right after i modified my code as below. However, nic_begin_packet_rx() still returns an invalid number, eg. 3FFC, since maximum size of a data frame is only 1.6 kbytes.

if (nic_begin_packet_rx() && t == 0) {
i++;
nic_packet_get_data(&buffer[0], 1600);
//nic_packet_get_data(&buffer[16], 16);
//nic_packet_get_data(&buffer[32], 16);
//nic_packet_get_data(&buffer[48], 16);
printf("PACKET %4LX : length : %4LX \n\r\n\r", i, nic_begin_packet_rx());

for (j=0; j < 0x10; j++) {
for (k= 0; k < 16; k++) {
printf(" %2X ", buffer[j * 16 + k]);
}
printf("\n\r");
}
// nic_packet_get_data(buffer, rx_len);
nic_end_packet_rx();
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group