Im reading a printscreen image from a scope that is in .gif format by sending a query to this scope. The returned data is in binary block form. I am communicating to this scope through a socket connection and using tcl. I could read the data fine, but when I try to write the data to a local file, it doesnt seem to write properly, as the created file has no information in it. Objective: to save or write this data to a local file so it can be accessed later.
Here's the piece of code trying to do the task in TCL.
#reading .gif data(binary block form) and writing it to a local file
fconfigure $channelid -encoding binary -translation binary ; #converts the stdin to binary data input
fconfigure $fileId -encoding binary -translation binary ; #converts the stdout to binary data output
set image [getdata $channelid "some query?"] ;# getdata proc reads the query returned data
puts stderr $image ;#to verify what data I am reading
set filename "C:/test.gif"
set fileId [open $filename "w"]
puts -nonewline $fileId $image
close $fileId
Any thoughts or help will be much appreciated. Thanks.