Web 51 - ip2hex.pl, mac2hex.pl

html2db.pl  software.html  RTL8019AS Packet Driver 1

Scripts mac2hex.pl and ip2hex.pl convert MAC and IP addresses into a format suitable for Web 51 development system. They were inspired by similar GPL'ed scripts by Bruce Lightner. Six forms of output are possible, selectable by command-line options.

  1. -define selects C-like definitions of constants:
    #define STATIC_MAC_MSB 00000h	/* MAC address  */
  2. -bat selects format usable in batch files:
    set MAC=0.0.232.238.16.53
  3. -equ selects A51 assembly include file format:
    MAC_MSB equ      00000h  ; MAC address
  4. -equ together with -binutils select mcs51-as include file format:
    .equ    MAC_MSB, 0x0000  ; MAC address
  5. -binutils alone selects mcs51-as-like definitions of data constants:
            .word   0x0000   ; Ethernet address 0.0.232.238.16.53
  6. If no -define/bat/equ/binutils is specified, A51 format for data constant definitions is used:
            dw      00000h   ; Ethernet address 0.0.232.238.16.53
  7. -v prints the entered MAC/IP address to standard error, as a debugging check.

MAC or IP address can be specified from the command line, contained in a file, or piped from another program. Output goes to standard output and can be redirected with usual syntax of the command interpreter, e.g.

 perl mac2hex.pl 00:00:E8:EE:10:33 > mac.inc

If the input is in a file, two specifications are possible:

  1. Enter the file name on the command line after the @ prefix:
    perl ip2hex.pl @file
  2. Redirect standard input, and terminate the command line with -. Under DOS32, several ways of redirecting standard input are possible, e.g.
    type ip | perl ip2hex.pl -
    or
    perl ip2hex.pl - < ip

If no arguments are given, a simple help is printed out:


 usage: ip2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] x.y.z.w
        ip2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] @file
        ip2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] - < file

 usage: mac2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] ddd.ddd.ddd.ddd.ddd.ddd
        mac2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] hh:hh:hh:hh:hh:hh
        mac2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] @file
        mac2hex.pl [-v] [-define] [-bat] [-equ] [-binutils] - < file

mac2hex.pl - Format of input (MAC address)

Two MAC address formats are allowed. First, dot-separated decimal numbers:

 0.0.232.238.16.51

Second, colon-separated hexadecimal numbers:

 00:00:E8:EE:10:33

Any lines that begin with # are assumed to be comments. A commented input file may look like:

 # default Web 51 Ethernet address
 00:00:E8:EE:10:33

ip2hex.pl - Format of input (IP address)

IP address is given as four dot-separated decimal numbers. Up to 4 entries may be specified, with the following meaning:

  1. IP Address of Web 51. Mandatory.
  2. IP Netmask. If unspecified, default of 255.255.255.0 is used.
  3. IP Gateway. If unspecified, default of 0.0.0.0 means no gateway.
  4. IP Partner. Specifies the IP address with which a connection is established, if there are incoming data from the serial line. Not all applications use this function. If unspecified, default of 0.0.0.0 turns off active establishing of connection

A specification of IP address can look like this:

 192.168.0.78 255.255.255.0 192.168.0.253 0.0.0.0

Any lines that begin with #. are assumed to be comments. A commented input file may look like this:

 # default Web 51 IP address
 #IP MASK GW POINT (target partner IP)
 192.168.0.78 255.255.255.0 192.168.0.253 0.0.0.0




Sponzored by LPhard Ltd. Graphics by GIMP Created by EasyPad

(c)Copyright 2000 - 2002, HW server & Radek Benedikt
Web51@HW.cz, Web51.HW.cz
html2db.pl  Obsah  RTL8019AS Packet Driver 1