Ethernet code

Newcomers to Astrobe and Oberon are welcome to ask any beginner-level questions here
Locked
Oberoid
Posts: 18
Joined: Fri Jan 28, 2011 8:57 pm
Location: Amsterdam, Netherlands

Ethernet code

Post by Oberoid » Tue Jan 15, 2013 2:52 pm

I would like to use Astrobe to program ethernet applications. Does anyone have experience with interfacing Astrobe with ethernet chips like the ENC28J60?

Greets,
Frans-Pieter

4GlCoder
Posts: 27
Joined: Fri Jul 22, 2011 2:47 pm

Re: Ethernet code

Post by 4GlCoder » Wed Jan 16, 2013 9:13 am

Yep, I've done so.
Be warned. Using the ENC28J60-H alikes means you need to REWRITE the entire TCP-IP stack. No Easy task because of sveral limitations in Astrobe Implementation. You can't simply port C-code...
A better alternative is to use the WizNet 5100 or WizNet5200 chip based solution which have the TCP-IP stack embedded in them. These are popular in Arduino environment. I have implemented code for Wiz820IO which is nearly the same HW config as ENC28J60-H but more versatile... at less than €20

Oberoid
Posts: 18
Joined: Fri Jan 28, 2011 8:57 pm
Location: Amsterdam, Netherlands

Re: Ethernet code

Post by Oberoid » Wed Jan 16, 2013 4:02 pm

Thanks for your considerations about the ENC28J60.
I thought that the ENC28j60 was an alternative for the Wiznet chips. Now i understand that the programming stack compilicates maters even more.

I use the arduino to experiment with microcontrollers with students. Take a look at the project at Lyceum in Hoofdorp, Netherlands.
http://www.dunamare.nl/scholen/haarlemm ... apjes.aspx
We are also tried to use the arduino as webserver with mildly succes.

With the arduino language the students are able to copy-repeat our instructions. However they find i very difficult to come up with solutions outside the offered code.
I think that Oberon is a better tool for learning and teaching programming.
To convince my colleagues and students I have to show a project written in Oberon that performs the same as the one in arduino. The first that comes to mind is a servo control program.

Concluding, I need arduino(wired) libraries like Servo an Ethernet ported to Oberon.
I would like to team up with anyone who wants to create arduino like drivers in Oberon.

Note: there is an arduino - oberon discussion going on at the oberon forum of the ETH Zurich.
oberon@lists.inf.ethz.ch

Greets,
Frans-Pieter fp@vonck.nl
Amsterdam, Netherlands

Alexander Shiryaev
Posts: 17
Joined: Mon Apr 04, 2011 7:20 pm
Location: Russia
Contact:

Re: Ethernet code

Post by Alexander Shiryaev » Wed Jan 16, 2013 5:07 pm

If you need Ethernet, it is not difficult. See EasyWEB sources for example.
If you need TCP, it is more complicated.

Oberoid
Posts: 18
Joined: Fri Jan 28, 2011 8:57 pm
Location: Amsterdam, Netherlands

Re: Ethernet code

Post by Oberoid » Wed Jan 16, 2013 9:12 pm

The wiznet5100 is a good start.
I found very readable example for programming the Wiznet5100 at this site.
The code is written for an avr micro
http://www.ermicro.com/blog/?p=1773

To give an impression how readable the code, see the following declaration part of the program wiznetping.c. There are only a few included headers.

Code: Select all

#include <avr/io.h>
#include <string.h>
#include <stdio.h>
#include <util/delay.h>

#define BAUD_RATE 19200

// AVRJazz Mega168/328 SPI I/O
#define SPI_PORT PORTB
#define SPI_DDR  DDRB
#define SPI_CS   PORTB2

// Wiznet W5100 Op Code

#define WIZNET_WRITE_OPCODE 0xF0
#define WIZNET_READ_OPCODE 0x0F

// Wiznet W5100 Register Addresses
#define MR   0x0000   // Mode Register
#define GAR  0x0001   // Gateway Address: 0x0001 to 0x0004
#define SUBR 0x0005   // Subnet mask Address: 0x0005 to 0x0008
#define SAR  0x0009   // Source Hardware Address (MAC): 0x0009 to 0x000E
#define SIPR 0x000F   // Source IP Address: 0x000F to 0x0012
#define RMSR 0x001A   // RX Memory Size Register
#define TMSR 0x001B   // TX Memory Size Register
So the code from emerico.com could be a start for a Astrobe w5100 Ping example.

I also looked at Project Oberon network solution. They used a protocol that looks somewhat similar to UDP. So that could be the next step.

Greets,
Frans-Pieter

4GlCoder
Posts: 27
Joined: Fri Jul 22, 2011 2:47 pm

Re: Ethernet code

Post by 4GlCoder » Wed Jan 16, 2013 10:46 pm

What Hardware do you (intend to) use?; Astrobe is especially targeted to NXP processors.
Arduino is mostly AVR & 8 bit based except for the recently introduced Arduino Due.
I would love to see Astrobe / Oberon M07 run on this though..

Oberoid
Posts: 18
Joined: Fri Jan 28, 2011 8:57 pm
Location: Amsterdam, Netherlands

Re: Ethernet code

Post by Oberoid » Wed Jan 16, 2013 11:54 pm

I use an embedded artist educational board lpc 2138
I have a personal licence for astrobe edition 4.0.2

The example code above is indeed written for avr, but it is well documented.
The arm (in c) examples from Keil if find confusing.

Did you already have written a module for the wiznet5100?

Oberoid
Posts: 18
Joined: Fri Jan 28, 2011 8:57 pm
Location: Amsterdam, Netherlands

Re: Ethernet code

Post by Oberoid » Fri Jan 18, 2013 11:55 pm

To wrap it up:
today i programmed an arduino to contol a servo, some switches and leds.
It worked, however from a didactal perspective, very difficult te explain to students.
The major problem are the unqualified imports. All kinds of procedures are used without reference. Besides, the arduino IDE does not guide you through the libraries for specifications.
So I can use the arduino to make some quick and dirty projects but it is not of much value from a educational perspective. The students can copy but are hindered to create for themselves.
Therefore, again, I stick to Oberon.
This concludes my request for ethernet code. My next questions will be less ambitious.

Greets,
F.P.

Locked