| |
serdev.pwp
//
// PicoWeb Project File for "SerDev"
//
// Demonstrates connection to external device via the PicoWeb
// serial port. The sample device is a Micromint Answer MAN Jr.
// The Answer MAN Jr. is a low-cost stand-alone data-acquisition
// and control module with a serial port for setup and/or data
// acquisition. The project has one Web page which automatically
// reloads itself every few seconds, thus sending a command to the
// Answer MAN via the PicoWeb serial port, reading the single-line
// response back, and displaying the response as the Web page.
// The Answer MAN response line is normally terminated with a
// carriage-return and new-line. If the Answer MAN fails to
// respond with a line-feed in a timely way, the PicoWeb CGI
// program will "timeout" and return a blank Web page.
//
#define EEPROM_IP /* IP address stored in EEPROM */
#define NET_CONFIG_IP /* allow IP address reconfiguration via net */
#define ENABLE_WATCHDOG
#undef DEBUGGER /* no debugger...we're using serial port */
//#define CLOCK 8000000
#define CLOCK 7372000
#define BAUD_RATE 9600
// HTML and images
serdev.htm
// CGI routines
sertest.cgi
answerman_all.cgi
//------------------ included AVR assembly language follows ---------------
#avr_reset
#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
;
; sertest
;
; Send command from URL parameter string to serial port and
; output response back from serial port
;
sertest:
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
pcall serdev_copynet ; copy serial port input to net
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
.eseg
answerman_all:
ppushn putcok,1 ; save putchar enable state
pmovbi putcok,0xff ; putchar is now OK
putchar_serial ; switch putchar to serial port
serial_binary ; put serial port in binary mode
pprint "\r! MAN0 QE\r" ; send "canned" command to serial port
pjump get_response ; read back response from serial port
Back
|
|
|