| |
hpmm.pwp
//
// PicoWeb Project File for "HPMM"
//
// Demonstrates connection to external device via the PicoWeb
// serial port. The sample device is an HP 34401A Multimeter.
// The "extra" PicoWeb RS-232 "modem control" lines are wired
// to DSR and DTR on the HP meter.
//
// This project makes use of Javascript to format the ASCII
// floating point voltage readings returned by the HP multimeter.
//
// This project can be loaded into the PicoWeb server and
// run without an actual HP multimeter present by using the
// "DUMMY_DATA" define statement.
//
#define EEPROM_IP /* use file "ip" for IP address */
#define NET_CONFIG_IP /* allow IP address reconfiguration via net */
#define ENABLE_WATCHDOG /* use Atmel watchdog timer hardware */
#undef DEBUGGER /* no debugger...we're using serial port */
//#define CLOCK 8000000
#define CLOCK 7372000 /* processor clock rate (Hz) */
#define BAUD_RATE 9600 /* serial port baud rate */
#define DUMMY_DATA "1.23456E-03" /* define to run with no meter present */
#define DSR_BIT 5 /* DSR, inverting output, DB25-11, DB9-6, PD2 */
#define DSR_PORT PORTD
#define DSR_PINS PIND
#define DSR_DDR DDRD
#define DTR_BIT 6 /* DTR, inverting input, DB25-15, DB9-4, PD2 */
#define DTR_PORT PORTD
#define DTR_PINS PIND
#define DTR_DDR DDRD
// HTML and images
hpmm.htm // home page
hpmm1.htm
hpmm2.htm
hpmm3.htm
hplogo.jpg
// CGI routines
send_cmd.cgi
//------------------ included AVR assembly language follows ---------------
#avr_reset
sbi DSR_DDR,DSR_BIT ; make output
cbi DTR_DDR,DTR_BIT ; make input
cbi DSR_PORT,DSR_BIT ; "DSR" => high (inverting output)
#avr_slow
#avr_fast
#avr_asm
#define putchar_serial pmovbi putc_b,0
#define putchar_net pmovbi putc_b,1
#define serial_binary pser_mode 1
#define serial_normal pser_mode 0
.eseg
;
; send_cmd
;
; Send command from URL parameter string to serial port and
; output response back from serial port
;
send_cmd:
putchar_serial ; switch putchar to serial port
serial_binary ; put serial port in binary mode
pcall serdev_print_url_cmd ; send command from URL string
get_response:
putchar_net ; switch putchar back to ''net
#ifdef DUMMY_DATA
pcall send_dummy_data ; return dummy data instead
#else
pcall serdev_copynet ; copy serial port input to net
#endif
pret
;
; print_cmd
;
; Read command from URL parameter string and output
;
print_cmd:
pmovwi buf+2,0
pjump serdev_print_url_cmd1
;
; serdev_print_url_cmd
;
; print command string in URL after "C="
;
serdev_print_url_cmd:
pmovwi buf+2,1
serdev_print_url_cmd1:
purlparm buf,"C=" ; search for command string
pjumpne 1f ; exit if not found
pprinturl buf,[buf+2]
1:
pret
;
; serdev_copynet
;
; loop reading chars from the serial buffer and writing to ''net until
; LF encountered (or timeout)
;
.cseg
serdev_copynet:
psgetcto buf,PSGETCTO_MSECS(1000) ; get char from UART with 1s timeout
pjumpeq serdev_copydone ; no more chars!
pcmpbi buf,0x0a ; check for LF (exit if found)
pjumpeq serdev_copydone
pputcb buf ; output character
pjump serdev_copynet ; back for more
serdev_copydone:
pret
;
; Send dummy data in place of HP multimeter
;
.eseg
send_dummy_data:
pprint DUMMY_DATA
pret
Back
|
|
|