⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vfd.tcl

📁 smartbits二次开发示例代码
💻 TCL
📖 第 1 页 / 共 2 页
字号:
########################################################################################################
#VFD.TCL                                                                                               #
#                                                                                                      #
# This script that demonstrates VFD usage by:                                                          #
#                                                                                                      #
# - Sets up VFD1 to overlay the MAC Destination area with a broadcast pattern (FF FF FF FF FF FF),     #                     #                                                                                                      # 
# - Sets VFD2 to overlay the MAC Source area with an incrementing pattern starting with                #
#   00 11 22 33 44 55.                                                                                 #
# - Sets up VFD3 to create a repeating cycle of different Ethertypes.                                  #                     #                                                                                                      #
# NOTE: This script works on the following cards:                                                      #
#       - 10 Mbps                                                                                      #
#       - SX-72XX/74XX                                                                                 #
#       - L3-67xx                                                                                      #
#       - ML-7710                                                                                      #
#       - ML-5710                                                                                      #
#       - LAN-6100                                                                                     #
#       - LAN-6101A                                                                                    #
#       - GX-1405(B)                                                                                   #
#       - GX-1420(B)                                                                                   #
#       - LAN-6200A                                                                                    #
#       - LAN-3300A/3301A/3302A                                                                        #
#       - LAN-3310A/3311A                                                                              #
#       - LAN-3306A                                                                                    #
#       - LAN-332xA                                                                                    #
#       - LAN-3710A                                                                                    #
#       - XLW-372xA                                                                                    #
#                                                                                                      #
########################################################################################################


if  {$tcl_platform(platform) == "windows"} {
      set libPath "../../../../tcl/tclfiles/et1000.tcl"
} else {
         set libPath "../../../../include/et1000.tcl"
}

# if it is not loaded, try to source it at the default path
if { ! [info exists __ET1000_TCL__] } {
     if {[file exists $libPath]} {
          source $libPath
   } else {   
               
            # Enter the location of the "et1000.tcl" file or enter "Q" or "q" to quit
            while {1} {
         
                        puts "Could not find the file $libPath."
                        puts "Enter the path of et1000.tcl, or q to exit." 
          
                       gets stdin libPath
                       if {$libPath == "q" || $libPath == "Q"} {
                            exit
                       } 
                       if {[file exists $libPath]} {
	                    source $libPath
                       break
                       } 
       
            } 
   }
}

# If chassis is not currently linked prompt for IP and link  
if {[ETGetLinkStatus] < 0} {
     puts "SmartBits not linked - Enter chassis IP address"
     gets stdin ipaddr
     set retval [NSSocketLink $ipaddr 16385 $RESERVE_NONE]
     if {$retval < 0 } {
	puts "Unable to connect to $ipaddr. Please try again."
	exit
	}
}


set iHub 0
set iSlot 8
set iPort 0

set iHub2 0
set iSlot2 8
set iPort2 1

set NUM_FRAMES 20
set DATA_LENGTH 60
set VFD_LENGTH 6

puts "Starting VFD.TCL..."

# Reserve the cards
LIBCMD HTSlotReserve $iHub $iSlot
LIBCMD HTSlotReserve $iHub2 $iSlot2

#Sets up the card to transmit a single burst of NUM_FRAMES packets,
#each DATA_LENGTH long (plus four byte CRC). With defaults this 
#means a single burst of twenty, 60-byte packets.
puts "Setup transmit parameters"
LIBCMD HTTransmitMode $SINGLE_BURST_MODE $iHub $iSlot $iPort

LIBCMD HTBurstCount $NUM_FRAMES $iHub $iSlot $iPort

LIBCMD HTDataLength $DATA_LENGTH $iHub $iSlot $iPort

########################################################################################################
# Fill in background data                                                                              #
#                                                                                                      #
# - Since the default fill is all 0, the background is filled with some other                          #
#   pattern, so that we can see that your program is writing to the card,                              #
#   and to be able to see the length of your fill pattern.                                             #
# - This sets the entire 60 byte packet length to all A's.                                             #
# - Anything that is not overlaid with a VFD will be an A.                                             #
# - If a VFD overlays an area with 0's instead of the intended pattern, you know                       #
#   that the VFD is working, but there may be a problem with the structure holding                     #
#   your data.                                                                                         #
########################################################################################################
struct_new filldata Int*$DATA_LENGTH
for {set i 0} {$i < $DATA_LENGTH} {incr i} {
	set filldata($i.i) 0xAA
}
LIBCMD HTFillPattern $DATA_LENGTH filldata $iHub $iSlot $iPort
unset filldata

########################################################################################################
# Fill in VFD1 data:                                                                                   #
#                                                                                                      #
# - Configuration $HVFD_STATIC means the same VFD will be over-laid onto every packet.                 #
# - In this case:                                                                                      #
#   - A loop is used to fill the structure vfd1Data with all FF (broadcast).                           #
#   - The Range value is set to 6.                                                                     #
#   - VFD 1 and 2 have a maximum length of 6 bytes.                                                    #
#   - The offset of 0 bits (note that Offset is in bits - all other parameters are in bytes).          #
#   - An Offset of zero bits with a Range of 6 bytes means this VFD will overlay the MAC Destination   #
#     area of the packet as follows (XX indicates non-VFD bytes in packet):                            #
#     FF FF FF FF FF FF XX XX XX XX XX XX etc.                                                         #
########################################################################################################

puts "Setup VFD1"

struct_new vfdstruct HTVFDStructure
set vfdstruct(Configuration) $HVFD_STATIC
set vfdstruct(Range) $VFD_LENGTH
set vfdstruct(Offset) 0

struct_new vfd1Data Int*$VFD_LENGTH
for {set iCount 0} {$iCount < $VFD_LENGTH} {incr iCount} {
	set vfd1Data($iCount.i) 0xFF
}

set vfdstruct(Data) vfd1Data
set vfdstruct(DataCount) 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -