Submitted-by: michaeli@stout.atd.ucar.edu Archive-name: xmodem/part06 #!/bin/sh # this is xmodem.06 (part 6 of xmodem) # do not concatenate these parts, unpack them in order with /bin/sh # file xmodem/README.vxWorks continued # touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo 'WARNING: not restoring timestamps' fi rm -f 1231235999 $$.touch # if test ! -r _sharseq.tmp; then echo 'Please unpack part 1 first!' exit 1 fi shar_sequence=`cat _sharseq.tmp` if test "$shar_sequence" != 6; then echo "Please unpack part $shar_sequence next!" exit 1 fi if test ! -f _sharnew.tmp; then echo 'x - still skipping xmodem/README.vxWorks' else echo 'x - continuing file xmodem/README.vxWorks' sed 's/^X//' << 'SHAR_EOF' >> 'xmodem/README.vxWorks' && X This code was originally created under vxWorks version 5.02b. It has been updated to run under vxWorks version 5.1.1. Unfortunately, you will need to do some system dependent hacking to get this up and running on your machine. Specifically: X X 1) Modify "rtcTime.fixme.c". You need to interface a clock X to the routine "rtcUpdateTime()" in that file. The other two X routines in that file already work, and they simulate X Unix time() and ctime() library routines. Rename the fixed X version to "rtcTime.c". I believe that the sysClock in vx 5.1 X can now be used for time keeping too, so that is another option. X The ctime() routine is included in vx5.1. The rtcTime.c will X have to be added to the Makefile if you use it. X 2) A Unix utime() command to set incoming files to their original X time/date is an optional item. I neglected this since it was X not possible to make one generic across all disk drivers. The X consequence is simply the incoming files are time stamped X to whatever the vxWorks disk driver sees fit. X 3) A vxWorks ioctl call that gets tty speed would also be sorta X useful, although I neglected this too, and just used a default X of 1200 baud. This can slow down the file receive function if X a higher baud rate is used, since the program will sleep the X time needed for 100 characters at 1200 baud to be received. To X change this edit the routine getspeed() in the file "getput.c". X 4) If your machine is not a 680x0, and it handles calling argurments X in a different manner, you will have to modify the argv/argc X creation in xmodem.c X RUNNING XMODEM UNDER VXWORKS X Since vxWorks does not use the standard argv and argc parameters, they were kludged in. The result of this is that you MUST terminate your argurment list with a 0 to prevent run-away stack access, and a probable crash. Some ambitious soul could add a check if argc goes over some limit, say 25, but since the shell rounds out parameter lists to about 10 fields, which usually automatically adds 0s to tasks, this did not seem to be worth the effort. Here is an example of using xmodem in the shell to receive a file: X X xmodem "-rt", "mfile.txt" X The program uses stdin, stdout, and stderr for I/O, and it uses the pwd to grab and save files. If you use this program in something other than the shell environment, make sure your I/O and path are setup using the vxWorks ioTaskStdSet, and ioDefPathSet before executing the program. One last thing: vxWorks DOES NOT SUPPORT WILDCARD filenames, so when sending files in the batch mode, each file must be explicitly named. The vxWorks archived contain dirLib which does handle wildcards and can be fairly easily slapped together. X X Matt Michaelis X National Center for Atmospheric Research X P.O. Box 3000 X Boulder, CO 80307 X michaeli@ncar.ucar.edu X X X SHAR_EOF echo 'File xmodem/README.vxWorks is complete' && $shar_touch -am 0815110894 'xmodem/README.vxWorks' && chmod 0644 'xmodem/README.vxWorks' || echo 'restore of xmodem/README.vxWorks failed' shar_count="`wc -c < 'xmodem/README.vxWorks'`" test 2924 -eq "$shar_count" || echo "xmodem/README.vxWorks: original size 2924, current size $shar_count" rm -f _sharnew.tmp fi # ============= xmodem/rtcTime.fixme.c ============== if test -f 'xmodem/rtcTime.fixme.c' && test X"$1" != X"-c"; then echo 'x - skipping xmodem/rtcTime.fixme.c (File already exists)' rm -f _sharnew.tmp else > _sharnew.tmp echo 'x - extracting xmodem/rtcTime.fixme.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'xmodem/rtcTime.fixme.c' && /* rtcTime.c - Unix type time() and ctime() routines */ X /* This stub created by Matt Michaelis, NCAR, but you have to make it work */ X /* modification history -------------------- 01a,28jul93,mcm Whacked this together from rtc stuff I generated a few months X ago. */ X /* DESCRIPTION This file contains two Unix type time routines that need to be interfaced to a real time clock. I included a prototype rtcUpdateTime routine which will need to be filled in or replaced. X FIXME WORK NEEDED The rtcUpdateTime routine. */ X #include "vxWorks.h" #include "types.h" X #define BASE_YEAR 1990 /* This is for clocks that have two digit years */ X LOCAL int rtcYear; LOCAL int rtcMonth; LOCAL int rtcDayOfYear; LOCAL int rtcDayOfMonth; LOCAL int rtcDayOfWeek; LOCAL int rtcHour; LOCAL int rtcMinute; LOCAL int rtcSecond; LOCAL int rtc100sSec; LOCAL int rtcPm; X /******************************************************************************* * * rtcUpdateTime - updates time and date from rtc. * */ void rtcUpdateTime(void) X { X rtcYear = fixme; /* See definition of BASE_YEAR */ X rtcMonth = fixme; X rtcDayOfYear = fixme; X rtcDayOfMonth = fixme; X rtcDayOfWeek = fixme; X rtcHour = fixme; X rtcMinute = fixme; X rtcSecond = fixme; X rtc100sSec = fixme; X rtcPm = fixme; X } X /******************************************************************************* * * rtcUnixTime - get the time and date. * * PARAMTERS * a pointer to time_t location, may be null * * RETURNS * The number of seconds since 1/1/1970 00:00:00 GMT */ X /* Use this if your clock does not return dayOfYear */ /* short monthToDay[] = X {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; */ X time_t rtcUnixTime (tloc) time_t *tloc; X { X time_t tsecs; X X tsecs = 0; X rtcUpdateTime(); /* Get the current date and time */ X X tsecs += (rtcYear + BASE_YEAR -1970) * (365 * 24 * 60 * 60); X tsecs += ((rtcYear + BASE_YEAR - 1)/4 - 1970/4) * (24 * 60 * 60); X tsecs += (rtcDayOfYear -1) * 24 * 60 * 60; X tsecs += rtcHour * 60 * 60; X tsecs += rtcMinute * 60; X tsecs += rtcSecond; X if ((rtcPm) && (rtcHour != 12)) X tsecs += 12 * 60 * 60; X if (tloc != NULL) *tloc = tsecs; X return tsecs; X } X X /******************************************************************************* * * rtcConvUnixTime - convert the time and date from Unixtime to year, month, etc. * * PARAMTERS * a time_t value * * RETURNS * A pointer to a string containing the Date/Time in ASCII */ X char *monthTable [12] = X {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", X "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; X char *dayOfWeek [7] = X {"Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"}; X short monthToDay[] = X {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; short monthToDayLeap[] = X {31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; X /* short dayToMonth[] = X {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 31}; */ X char *rtcConvUnixTime (timInSec) time_t timInSec; X { X int year, month, day, date, num_days, hour, minute, sec; X static char asciiTime[26]; X time_t tsecs; X X num_days = timInSec / (24 * 60 * 60); X /* 1/1/1970 was a Thursday */ X day = num_days % 7; X year = 1970 + timInSec / (365* 24 * 60 * 60); X timInSec -= (year - 1970) * (365 * 24 * 60 * 60); X /* Remove leap year seconds from all but current year */ X timInSec -= ((year - 1)/4 - 1970/4) * (24 * 60 * 60); X X date = timInSec / (24 * 60 * 60); X timInSec -= date * (24 * 60 * 60); X date++; /* Change date origin from 0 to 1 */ X month = 0; X /* Check for not leap year */ X if (year % 4) X { X while(date - monthToDay[month] > 0) X month++; X if (month) date -= monthToDay[month - 1]; X } X else X /* Is a leap year */ X { X while(date - monthToDayLeap[month] > 0) X month++; X if (month) date -= monthToDayLeap[month - 1]; X } X X /* Now we are down to time of day */ X hour = timInSec / (60 * 60); X timInSec -= hour * (60 * 60); X minute = timInSec / 60; X timInSec -= minute * 60; X sec = timInSec; X X /* String format example: X * Sun Sep 16 01:03:52 1973\n\0 X */ X sprintf(asciiTime, "%s %s %02d %02d:%02d:%02d %04d\n", X dayOfWeek[day], monthTable[month], date, hour, minute, sec, year); X X return &asciiTime[0]; X } SHAR_EOF $shar_touch -am 0812110094 'xmodem/rtcTime.fixme.c' && chmod 0644 'xmodem/rtcTime.fixme.c' || echo 'restore of xmodem/rtcTime.fixme.c failed' shar_count="`wc -c < 'xmodem/rtcTime.fixme.c'`" test 4328 -eq "$shar_count" || echo "xmodem/rtcTime.fixme.c: original size 4328, current size $shar_count" rm -f _sharnew.tmp fi rm -f _sharseq.tmp echo 'You have unpacked the last part' exit 0