AnsweredAssumed Answered

Uploading IBASIC Prog from External Controler to E5100A

Question asked by Wale on Feb 28, 2008
Latest reply on Mar 3, 2008 by Wale
Hi!

I could successful download an IBASIC program from the E5100A to my
PC. When I try to upload this downloaded Program to the E5100A I get only error messages (-102) Syntax Error.

Here my (working) code for the download:

bool TAnalyzerControl::ProgDownload (const TFile& file)
{
  char* buf;
  Tstring buffer = "";
  bool res = false;
     
  mGpib->Send (mDeviceID, "PROG:DEF?");
     
  do
  {
    res = mGpib->Enter (mDeviceID, &buf);
    if (res)
    {
      buffer += buf;
      if &#40;strlen &#40;buf&#41; < 1024&#41;
        res = false;
    &#125;
    else
      return false;
  &#125; while &#40;res&#41;;

  StringVect program = Split &#40;buffer, LF&#41;;
  Tofstream os &#40;file.FullPathName &#40;&#41;.c_str &#40;&#41;&#41;;
  if &#40;os.good &#40;&#41;&#41;
  &#123;
    for &#40;UInt i = 0; i < program.size &#40;&#41;; ++i&#41;
    &#123;
      Tstring line = program&#91;i&#93;;
      UInt pos = line.find_first_of &#40;CR&#41;;
      if &#40;pos != line.npos&#41;
        line = line.substr &#40;0, pos&#41;;
      if &#40;!line.empty &#40;&#41;&#41;
        os << line << endl;
    &#125;
  &#125;
  else
    return false;

  return true;
&#125;


and here my (not working) code for the upload:

//----- ProgUpload
bool TAnalyzerControl::ProgUpload &#40;const TFile& file&#41;
&#123;
  Tifstream is &#40;file.FullPathName &#40;&#41;.c_str &#40;&#41;&#41;;
  if &#40;is.good &#40;&#41;&#41;
  &#123;
    Tstring line;
    mGpib->Send &#40;mDeviceID, "PROG:DEL:ALL"&#41;;
    mGpib->Send &#40;mDeviceID, "PROG:DEF #0"&#41;;
    while &#40;is.good &#40;&#41;&#41;
    &#123;
      line = "";
      getline &#40;is, line&#41;;  // here the line looks correct
      if &#40;!line.empty &#40;&#41;&#41;
      &#123;
        line += "\r\n";  // I tried without this, was not working too
        mGpib->Send &#40;mDeviceID, line.c_str &#40;&#41;&#41;;
      &#125;
    &#125;
  &#125;
  return false;
&#125;


- I used the examples from the "Programming Manual" Page 6-7.
- I tried with the Header Number (ex. #6005466) and without the Header Number.
- I tried with saving the program on the E5100A to disk and the uploading this program

Nothing worked and I run out of ideas 

Any help highly appreciated.

Best Regards
Wale  

Outcomes