Web 51 - ip2hex.pl, mac2hex.pl |
|
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.
- -define selects C-like definitions of constants:
#define STATIC_MAC_MSB 00000h /* MAC address */- -bat selects format usable in batch files:
set MAC=0.0.232.238.16.53- -equ selects A51 assembly include file format:
MAC_MSB equ 00000h ; MAC address- -equ together with -binutils select mcs51-as include file format:
.equ MAC_MSB, 0x0000 ; MAC address- -binutils alone selects mcs51-as-like definitions of data constants:
.word 0x0000 ; Ethernet address 0.0.232.238.16.53- 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- -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.incIf the input is in a file, two specifications are possible:
- Enter the file name on the command line after the @ prefix:
perl ip2hex.pl @file- Redirect standard input, and terminate the command line with -. Under DOS32, several ways of redirecting standard input are possible, e.g.
ortype ip | perl ip2hex.pl -perl ip2hex.pl - < ipIf 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
Two MAC address formats are allowed. First, dot-separated decimal numbers:
0.0.232.238.16.51Second, colon-separated hexadecimal numbers:
00:00:E8:EE:10:33Any 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
IP address is given as four dot-separated decimal numbers. Up to 4 entries may be specified, with the following meaning:
- IP Address of Web 51. Mandatory.
- IP Netmask. If unspecified, default of 255.255.255.0 is used.
- IP Gateway. If unspecified, default of 0.0.0.0 means no gateway.
- 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.0Any 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
| Web51 description | News | FAQ | ORDER FORM | DOWNLOAD | Links |
| (c)Copyright 2000 - 2002, HW server & Radek Benedikt
Web51@HW.cz, Web51.HW.cz |
|