My understanding of ArcNet protocol

What is ArcNet?

Attached Resource Computer Network is a communication protocol widely used in build automation. This protocol is very efficient in Local Area Network, wherein multiple devices want to share information at faster phase. Core functionality of this protocol relies on token passing between nodes. Better analogy could be, consider network as a shared object and token as the key to the object.

What are other features?

Data speeds up to 10Mpbs, Variable packet lengths, Supports Bus or star topology, Uni-cast and broadcast messages.


Let’s dive into each message types in the protocol.

RECON – Reconfiguration

This is another important message or feature to keep track of the network changes. This message can be triggered in following cases:

  1. When a node joins the network
  2. When a node leaves the network
  3. For high performance, it can be triggered every 20 – 30ms

image007

ITT: Invitation to Transmit

Token is the identifier for the node or the device in the network. When node enters the network it sends a RECON message. This message will inform the network about change in configuration of the network and re-start the token passing.

Let’s take a simple example of a network.
picture1

Now node 1 starts the token passing, it will send out ITT message to destination nodes starting from next address of its current address. In our case it would be 0x0B. It keeps on sending ITT until it receives the response from any node in the network.

image003

Now as you can see, 0x02 node has responded to the request from 0x0a. Now the token is with 0x02 node, so it starts it token parsing to find out another node in the network.

When ITT message reached the destination as 0x05, node three responds takes on the task of token parsing. Then it identifies the another node that is i.e 0x0a. So token passing happens until all nodes in the network are identified. For our setup the intial token passing is completed we have a network 0x0A <-> 0x02 <-> 0x05 <-> 0x0a.

After accomplishing the network and identifying the nodes in the network. The token passing keeps on continuing as shown below for efficient data transfer.

image005

How? say for example 0x0a wants to send some data to 0x05. It can send the data only when it has the token. As I said earlier, token is kind of key to the network infrastructure and resources.

FBE – Free Buffer Enquiry

Before a nodes a sends packet to another node, it needs to know if the receiver can accept incoming packets.

When the node has the token, it would send a FBE request to receiving node. The receiver can chose to send ACK or NAK.

FBE with NAK/ACK is shown below

image009

PAC: Packet

This is the message protocol to send data frames to the receiving node. The data could be anything.

The frame contains Source address node, destination node, length and the actual data. The receiver can ACK or NAK the transmission.

PAC sequence is shown below:

image012

ACK: Acknowledgement

Sent by receiving node to the sender about accepting the information sent

NAK: Negative Acknowledgement

Sent by receiving node to the sender about rejecting the information sent

 

Ideas on Designing Software based on my experience

I am going to put forth my ideas based on my experience. Software designing needs lots of patience and need to be open to ideas or changes. The first few phase are very trivial for software design. I had an opportunity of designing three software from conceptual phase.

1.Gathering the requirements

May be this sounds easier, but believe me it needs your time. For the first software which i designed, it took me two months for requirement elicitation. First step is to find out whether the product is for the internal or external customers. Both customers are very unique, internal customers are critics and external customers are consumers.

After determining the customers, bring the stake holder in for a discussion and understand the following:

  1. What is the end goal of the product?
  2. What is scope of adding features in future ?
  3. Is it aligned to the market trend
  4. What is the targeted time frame ?

These discussions will give you a fair idea about the software/product and it will be easier for you to communicate in their language. Create a database to store all the meeting minutes, requirements documents. Go through the requirements document and create an understanding document based on your understanding about the requirement and get it reviewed by the stake holders.

Initial tough phase is completed.

2. Finalize the technology

Now you have a fair idea about the product. Do a market research about the softwares that can be used, just to give an example.

Technology Difficulty level Is it easier to maintain License Is support available
C Medium yes GPL Yes, online forums

This phase is also very trivial since this is going to determine path for rest of your project.

3. Proof of concept

According to me, this is where your software gets life. This phase can eliminate the unnecessary complication on platform, technology. In my first project i ignored this phase and it lead to major complications. We were to design a cross platform software for a Embedded product. My fellow engineers chose wxWidgets just based on the initial market research. The development went fine on one platform until time came to test on windows, the entire software broke. We ended up debugging the software to create work around.

So don’t do this mistake. This phase will not resolve any un foreseen issue, but it will at least give you an heads up.

4. Decide on the design pattern

Here comes the dilemma, there are more design patterns available than anticipated. In phase 3 you might get some idea about the working of the software in very high level. Use that understanding to zero in on design patterns. A piece of advise, have two or three design patterns as fall back position.

5. Decide on building blocks/modules

The design should be structured, easier to maintain and expendable. Create building blocks of the software and find a common blocks which can be used by all modules. Blocks not the very low level of coding, I am just talking about the modules.

I will take an example of GSM messaging, Layer 3 messaging RR,CC, SMS etc,

Building blocks - Software

I created base block for the all the layers to be able to control completely if any changes in future.

6. Communication channel between modules

We have decided on the modules, number of building blocks and common blocks. Now we need to finalize on the mode of communication between these blocks. In my first project the softwares includes four services, a. Main GUI or tracing b. Configuration management c. Clock d. Simulation components. So How did i decide on the communication mechanism, its simple. First draw a map about who’s is going use those modules, is there any updates required during run time.

So in my case the configuration server holds all the information about the current running instance and needs to be update in runtime and broad casted. So i decided to go for a client server design on sockets, one for updating data and another for broadcast.

Communication - software.png

In your case it could be just a function call.

7.  Designing individual modules

If you have reached this phase, you have complete understanding of the software by now. The modules are tap points for the application layers. So make sure you make it very generic so that it can be completely controlled by the application layer. For instance we will take the GUI wants to connect to a server

GUI module:

function_connect_to_server();

Instead of this you can have

function_connect_to_server(url, password,username… etc);

8. Design document

You may be an architect but in order to make your design rolling, you need to document. Keep in mind that the engineer does not have extensive knowledge, since he/she is not involved from conceptual phase. In first project i got this wrong and assumed the engineer knows.

After you document the design, make sure to get the design review by SME’s, stake holders. This will give a chance to correct the design, if you have missed any trivial part. This does not mean that you have got all requirement correct 🙂

Before closing up this discussion. The above mentioned points are purely based on my experience. I always strive to make the design make very generic and to embrace changes based on the customer experience.

Good luck in your software design.

Auto login in TI-SDK, Am335x

I have been working with TI-SDK for past two years and every time i come across some interesting trivia posed by the systems engineers 🙂 . One of such request was to enable automatic login in tisdk. The idea is to lead the user directly to command prompt after kernel boot up. I tried several approaches over weeks, and zeroed in on the following simpler approach.

I am going to run through serious of steps followed to enable auto login in tisdk or embedded linux.

The setup which I used:

Version : TISDK 7.0

Hw: AM335x

Rootfs: Hosted on Network file system on ubuntu [ which is a guest OS on Vmware]

Firstly I need a configuration file for setting username and password. I can just hard code in the tool but want to give user the control.

The configuration file looks like:

#cat /etc/autologin.profile

root,root

Then I wrote a small tool to read the username and password from configuration file and use /bin/login for login to the shell..

// Autologin.c

// GPL, Author: Johnnie J. Alan

#include <unistd.h>
#include <stdio.h>

int main()
{
int nrv = 0;
FILE* fptr = 0;
char user[64];

char pass[64];

// clear buffer
memset(user,’\0′,64);

// open autologin profile file
fptr = fopen(“/etc/autologin.profile\0″,”r\0″);

// make sure the file exists and was opened
if (fptr != 0)
{
// the return value from fscanf will be 1 if the autologin profile name is read correctly
nrv = fscanf(fptr,”%s,%s\0”,user,pass);
}

// only autologin if the profile name was read successfully,
// otherwise show the regular login prompt
if (nrv > 0)
nrv = execlp(“login”,”login”,”-f”,user,0);
else
nrv = execlp(“login”,”login”,”\0″,pass,0);

return 0;
}

Note: you can change this according to your needs

I cross compiled the tool for ARM and placed the compiled tool in /sbin

arm-linux-gnueabihf-gcc -o autologin autologin.c

Then I changed the init scripts to reflect the changes, basically setting up getty. My setup uses Uart0 port for console.

The configuration for the console is present in /etc/inittab. The changes which I made is highlighted below.

#Johnnie S:2345:respawn:/sbin/getty 115200 ttyO0
S:2345:once:/etc/init.d/myloginShell

The file myloginShell is just used for my configurations, the idea is to isolate my changes from the defaults.

The contents of the myloginShell is

#!/bin/sh

# I have removed some of other configuration which is not relevant for this post.

showLogin=1
if [ $showLogin -eq 1 ]; then
while true; do
# This is line which is important. ttyO0 indicates by Uart0 console port

# I am asking getty to use my tool instead of /bin/login which is default.
/sbin/getty -n -l /sbin/autologin 115200 ttyO0
exitCode=$?
if [ “$exitCode” = “129” ]; then
break;
fi
done
else
stty -echo
fi

Viola, You have the setup ready to automatic login.

You can also do the same in inittab itself.

#Johnnie S:2345:respawn:/sbin/getty 115200 ttyO0
S:2345:respawn:/sbin/getty -n -l /sbin/autologin 115200 ttyO0

Thanks for reading this post and Happy logging.