Realtek network adaptor 8168E transmit/receive using loopback - driver

I am trying to transmit and receive from Realtek 8168E using loopback(For windows 7 platform) ( writing into tx buffer and reading from rx buffer)
Reading rx buffer gives 0.
On checking interrupt status register, TDU and RDU bit is set to 1 (Tx/Rx descriptor unavailable)
Network adaptor : Realtek 8168E
Data sheet referred : Realtek 8168B
Transmitter side configuration
- Allocated a memory for TX descriptor as per the specification given in the data sheet (page no:55).
Aligned descriptor to 256 byte alignment.
Also allocated a separate buffer (TXBuffer) to store the data to be transmitted.
Placed the address of TXBuffer into the specified field in the TX descriptor.
Enabled the MAC loopback bit in the TX config register (40h).
Then we have enabled the NPQ bit in the TxPoll register (38h).
After that, we have done the NIC reset by offset 37h.
Then we have enabled the loopback bit in BMCR register.
Enabled the Tx OK, and Tx Descriptor Unavailable interrupts in interrupt mask register (3Ch).
Placed the Tx Descriptor address into the MAC register TNPDS (20h).
Then at last enabled the TE bit in command register (37h).
Similarly I did required configuration in Rx side.
Below are the buffer I have Given
//TX Buffer desriptor
typedef struct _TMP_TBD_STRUC {
ULONG ulFrameLength;
ULONG VLAN_TAG;
ULONG TX_Buffer_Add_Low;
ULONG TX_Buffer_Add_High;
} TBD_TMP_STRUC, *PTBD_TMP_STRUC;
//RX Buffer desriptor
typedef struct _RMP_RBD_STRUC {
ULONG ulBufferSize;
ULONG VLAN_TAG;
ULONG RX_Buffer_Add_Low;
ULONG RX_Buffer_Add_High;
} RBD_RMP_STRUC, *PRBD_RMP_STRUC;
*PL. suggest with how to debug such situation.
Also the correct seqeunce of Tx & Rx descriptor configuration, pl share.
*

Related

ESP8266 not working after baud rate change

Hello guys I have my ESP8266 connected to my Arduino. Then I typed in AT in the serial monitor. It confirmed this command with OK. After that I typed in AT+UART=9600, 8, 1, 0, 0 which gave me the response ERROR. Then I googled what I could do, which told me that I should try change the baud rate permanently with the command AT+IPR=9600. I did this but I got no response. After that I wondered if everything was ok so I typed in AT. No response. Now I'm a little bit sad because everything started to be great but I don't know how I can fix the whole problem. I also tried to upgrade its firmware with XTCOM Utility but it says it can't connect.
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup() {
Serial.begin(115200); // communication with the host computer
//while (!Serial) { ; }
// Start the software serial for communication with the ESP8266
ESPserial.begin(115200);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
}
void loop() {
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
This is my code. I tried it with both 9600 and 115200 but if I use 115200 the serial monitor just shows some garbage signs. It's kind of frustrating because I can't even interact with the serial monitor as my typed commands don't show up anymore. Do you have any idea how I could fix this problem?
EDIT:
I read that the command AT+IPR=9600 breaks the module and it can just be fixed by reflashing it. Sadly this doesn't work because it somehow can`t connect.

Unable to read serial/uart pins on NodeMCU

I am unable to read the serial pins in the NodeMCU Lua environment. I have only been able to read the USB serial port.
I have connected a serial adapter to the rx, tx, and g pins.
I have tried this code:
uart.on("data","\n",function(data) print("receive from uart:", data) end, 0)
I enter text in the ESplorer console and it does read that. It doesn't read anything I send over a serial adapter plugged into the rx/tx/g pins.
uart.write(0, "hello")
I disconnected the USB cable and powered it with the serial adapter. Nothing was sent using this code. I tried uart.write(0, and uart.write(1,.
How do I read the pin serial ports instead of the usb serial port?
I needed to unplug the USB cable. The device gets confused if the USB cable is plugged in and you're trying to use the pin serial port.
See my question on the esp forums:
https://www.esp8266.com/viewtopic.php?f=22&t=19768
You have to use different pins then the RX and TX as they are the same as the USB port you are connecting your NodeMCU with to your PC
You can use any other 2 free gpio pins as a serial port with the help of https://github.com/scottwday/EspSoftSerial library. This library is specificly for ESP8266 on which your NodeMCU is based.
This way you have 2 serial ports, one through the usb and another one to connect to other devices.
Some simpel code to implement the Software serial below.
#include <SoftwareSerial.h>
#define BAUD_RATE 9600
SoftwareSerial Serial2(D8, D7, false, 8); //Here you choose the pins you connect the RX TX device to
//The first pin you choose is RX the second TX
// in my example these are the D8 and D7 pins on the nodeMCU
// D8=RX .... D7=TX
void setup() {
Serial.begin(BAUD_RATE);
Serial2.begin(BAUD_RATE);
Serial.println(" ### Hello ###");
Serial2.println(" ### Hello ###");
}
void loop() {
}
}

Redpark Serial Cable Arduino iOS

I've used the RedPark seriable cable with iOS before however, I've only been using it to receive data from an Arduino. My ambition is to be able to transmit information from the iPhone to the Arduino also.
At the moment it's set up to receive
Arduino RX -> Redpark TX
Arduino TX -> Redpark RX
Arduino 5V -> Redpark 5V
Arduino GND -> Redpark GND
The example I used was to toggle the LED on an Arduino board...
void setup() {
Serial.begin(9600); // Start the serial port
pinMode(13, OUTPUT); // Set the built-in LED to output mode
}
void loop() {
if (Serial.available()) { // If there's anything on the serial port,
byte cmd = Serial.read(); // read a single byte from it.
if (cmd == '1') { // If the command is the character '1',
digitalWrite(13, HIGH); // set the LED on
}
if (cmd == '0') { // If the command is the character '0',
digitalWrite(13, LOW); // set the LED off
Serial.print(cmd, BYTE);
}
}
}
I also used the accompanying iPhone app with the Redpark serial cable. I have confirmed I am able tor receive text (using the default app that comes with the RedPark serial cable. So I know that when the iPhone is connected to the Arduino, I am able to receive transmitted data from the Arduino. I can't however transmit any data (the default app allows you to transmit data + the app confirms that the iPhone has sent data. However I am unable to fall into this method on the Arduino, when sending from the iPhone.
if(Serial.available())
{
...
}
For reference, the iPhone I'm using is the iPhone5 with the 30 pin to lightning adapter.

Communication using CC2520

My team has been trying to send data through a CC2520 using a
MSPEXP430F5438 board. We tried using the FIFO_READ and FIFO_WRITE
command but it was of no avail. We also tried using the RAM_READ and
RAM_WRITE command but still the results were the same. We checked the
interfacing of MSP430 and CC2520 and that seems fine. Could anyone
suggest some way to find out where our problem lies(sender/reciever)?
Regards, Pratyush
At a high level, the CC2520 is a SPI-controlled state machine. This means that the radio transceiver requires a particular sequence of commands to transmit or receive data.
I would recommend taking a look at Section 21 (page 85, when written) within the CC2520 Datasheet. Additionally, Section 19 and 20 shows the TX and RX procedure, respectively.
SmartRF Studio is often the easiest way to get started, as it has a full GUI interface to the radio. However, you may need to purchase the CC2520 dev kit or have a supported baseboard for the CC2520. I believe the MSP-EXP430F5438 board does not support SmartRF Studio, but I could not easily find the answer. I know SmartRF studio recognizes the MSP-EXP430F5438 when you launch the software, but I'm not sure the software can use the MSP-EXP430F5438 as a baseboard for the desktop GUI control of the radio.
If you want to program a "hello world" onto your MSP-EXP430F5438 and CC2520, I recommend using TI's provided sample code for the CC2520, and perusing the CC2520 page.
For TI's CCxxxx radios, in C pseudo-code, to transmit/send a message you might do the following:
SPI_Strobe(IDLE); /* Reset radio state machine to 'start' state (IDLE) */
SPI_WriteBurstReg(TXFIFO, tx_data, tx_data_length); /* Write data to TX FIFO */
SPI_Strobe(TX); /* Start radio transmission */
_BIS(LPM3+GIE); /* While TX finishes, sleep MCU with general interrupt enable */
/* Use GPIO to interrupt. When TX is finished, RETI from ISR */
/* and continue to next line */
SPI_Strobe(FLUSH_TXFIFO); /* Flush TX buffer (optional) */
SPI_Strobe(IDLE); /* Reset radio state machine to 'start' state (IDLE)
/* Can auto enter IDLE when TX done - see doc. */
SPI_Strobe(PWR_DOWN); /* Turn off radio to save power (optional) */
Above, I'm using all-caps to indicate a static address/byte definition from a header file.

Query Related to Packet traversal in kernel

After reading the book "Understanding Linux Network internals".
I came to know about some concepts of how we get the packet from the network:-
> When working in interrupt driven model, the nic registers an
> interrupt handler;
> • This interrupt handler will be called when a frame is received;
> • Typically in the handler, we allocate sk buff by calling
> dev alloc skb();
> • Copies data from nic’s buffer to this struct just created;
> • nic call generic reception routine netif rx();
> • netif rx() put frame in per cpu queue;
> • if queue is full, drop!
> • net rx action() decision based on skb->protocol;
> • This function basically dequeues the frame and delivery a copy
> for every protocol handler;
> • ptype all and ptype base queues
> ip v4 rcv() will receive the ip datagram (if is a ipv4 packet);
•ip checksum, check ip headers, ....
• ip rcv finish() makes route decision (ip forward() or ip local delivery())
Now i had some queries related to it that are:-
Regarding netif_rx() code on the link http://lxr.free-electrons.com/source/net/core/dev.c#L3075 which code says that it delivers the frame to upper layer
And regarding net_rx_action() http://lxr.free-electrons.com/source/net/core/dev.c#L4041 which code says that it takes decision based on skb->protocol
And Whats the packet transmission process i mean when is the sk_buff allocated and all.
Please guide

Resources