egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sending Email using TCL

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
derrick_chi
Voice


Joined: 21 Mar 2009
Posts: 3

PostPosted: Sat Mar 21, 2009 11:49 am    Post subject: Sending Email using TCL Reply with quote

Can anyone help me with this. I want to do something very simple which is to send an email message to my email account using a tcl script. For the life of me I can't seem to find out exactly how to do that. By the way I am using a pc, vista/xp.

Here is a simple script, and what it does is provide "random" IEEE standard floating point inputs to a floating point unit (I've designed in hardware), it then randomly choose to command the unit to add the inputs or subtract them, finally it monitors the outputs to check and see if the unit is operating correctly.

I am using the script to control a simulator which is actually providing the stimulus for my hardware and checking the outputs. Sooo when it does find an error I'd just like to receive an email notification. Thats pretty much it. Thanks in advance for your help.

TCL Script
-----------------------

do float_addsub_wave.do
restart
set UserTimeUnit ns

force -deposit RST 1
force -deposit CLK 1 0, 0 {10 ns} -r 20
force -deposit A 0
force -deposit B 0
force -deposit FLOAT_ADDSUB 0
force -deposit ADD_SUB 0

run 60 ns

force -deposit RST 0

set A_ARRAY(0) 0
set B_ARRAY(0) 0

proc myRand { dec_min dec_max } {
set hex_maxFactor [expr [expr $dec_max + 1] - $dec_min]
set dec_value [expr int([expr rand() * 100])]
set dec_value [expr [expr $dec_value % $hex_maxFactor] + $dec_min]
return $dec_value
}

proc myFloatRand { min max } {
set maxFactor [expr [expr $max + 1] - $min]
set value [expr ([expr rand() * $max])]
#set value [expr [expr $value / $maxFactor] + $min]
return $value
}

proc myRand_hex { dec_min dec_max } {
set hex_maxFactor [expr [expr $dec_max + 1] - $dec_min]
set dec_value [expr int([expr rand() * 100])]
set dec_value [expr [expr $dec_value % $hex_maxFactor] + $dec_min]
set hex_value [format %02x $dec_value]
return $hex_value
}

# The following procedures have been changed to single precision.

proc __reverse__ {s} {
for {set i [string length $s]} {$i>=0} {incr i -1} {
append sr [string index $s $i]
}
return $sr
}


proc floatToBinarLittleEndian_a {d} {
binary scan [binary format f $d] b* v
set v [__reverse__ $v]
set sign [string index $v 0]
set exponent [string range $v 1 8]
set mantissa [string range $v 9 end]
return [list $sign $exponent $mantissa]

}

proc floatToBinarLittleEndian_b {d} {
binary scan [binary format f $d] b* v
set v [__reverse__ $v]
set sign [string index $v 0]
set exponent [string range $v 1 8]
set mantissa [string range $v 9 end]
return "$sign$exponent$mantissa"

}

proc binarToFloatLittleEndian {ieee_float_single_precision} {

set v [binary format b32 [__reverse__ $ieee_float_single_precision]]
binary scan $v f v
return $v
}


set transaction_count 0


while {$transaction_count <= 10000 } {

set float_a [format %e [myFloatRand 7909.10987 4356456.987612345] ]
set float_b [format %e [myFloatRand 7909.10987 4356456.987612345] ]

set binary_a [floatToBinarLittleEndian_b $float_a]
set binary_b [floatToBinarLittleEndian_b $float_b]

binary scan [binary format B32 $binary_a] H8 bin2hex_a
binary scan [binary format B32 $binary_b] H8 bin2hex_b

#echo " $binary_a $bin2hex_a $float_a $binary_b $bin2hex_b $float_b "

set opcode [myRand 0 1]

if { $opcode == 0 } {

set IEEE_SUM [format %e [expr $float_a + $float_b] ]
set action "+"

} else {

set IEEE_SUM [format %e [expr $float_a - $float_b] ]
set action "-"
}

set IEEE_SUM_BINARY [floatToBinarLittleEndian_b $IEEE_SUM]

binary scan [binary format B32 $IEEE_SUM_BINARY] H8 IEEE_bin2hex_a

force -deposit A $bin2hex_a
force -deposit B $bin2hex_b
force -deposit FLOAT_ADDSUB 1
force -deposit ADD_SUB $opcode

run 20 ns

force -deposit FLOAT_ADDSUB 0
force -deposit ADD_SUB 0

run 20 ns

while { [examine -hex FINISHED] == 0 } {run 20 ns}

set IEEE_FLOAT [examine -hex float_sum_dif]

binary scan [binary format H8 $IEEE_FLOAT] B32 hex2bin_a

set SUM_DIFF [format %e [binarToFloatLittleEndian $hex2bin_a] ]

if { ($IEEE_SUM != $SUM_DIFF) && ( [expr abs([expr $IEEE_SUM - $SUM_DIFF])] > 1 ) } {

run 40 ns
error " The values do not match the correct answer to the equation $float_a $action $float_b is $IEEE_SUM ---> $IEEE_bin2hex_a instead you said it was $SUM_DIFF hex value ---> $IEEE_FLOAT "

} else {

echo " OK looks like its working the equation was $float_a $action $float_b = $IEEE_SUM and you said it was $SUM_DIFF hex value ---> $IEEE_FLOAT "
}

incr transaction_count

}
Back to top
View user's profile Send private message
Kein
Voice


Joined: 09 Apr 2008
Posts: 21

PostPosted: Mon Mar 23, 2009 9:07 am    Post subject: Reply with quote

you need a mail client which you can use via exec command
_________________
I'm too lazy for all of this
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Mon Mar 23, 2009 11:33 am    Post subject: Reply with quote

you can write your own proc based on sockets

or try this:
http://tcllib.sourceforge.net/doc/smtp.html
Back to top
View user's profile Send private message Visit poster's website
derrick_chi
Voice


Joined: 21 Mar 2009
Posts: 3

PostPosted: Mon Mar 23, 2009 12:14 pm    Post subject: Reply with quote

Hi

Thanks for your reply, I've actually tried this and it doesn't seem to work.

Does anyone have a proc which they use and know for sure works on windows?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber