LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows/CVI and NI-VISA

Bonjour,
J’utilise un code en C qui scanne les ressources VISA de type "ASRL[0-9]*::?*INSTR". Ce code fonctionne correctement sur plusieurs ordinateurs, mais sur certains, une erreur survient :

Erreur VISA dans viFindRsrc : VI_ERROR_RSRC_NFOUND (Ressource non trouvée, vérifiez la chaîne de recherche).

Pourtant, dans NI MAX, la ressource est bien détectée et fonctionne normalement.
Un comportement étrange se produit : si j’ajoute une nouvelle ressource VISA (par exemple, un autre port série), la première ressource commence à être détectée par mon code, mais pas la seconde.
En mode debug, la fonction viFindRsrc(hRM, "ASRL[0-9]*::?*INSTR", &findList, &numInstruments, desc); trouve bien la ressource. Cependant, lors de l’appel à viFindNext(findList, desc);, une erreur se produit avec le code -1073807343

cordialement

Frédéric BLANC LAAS-CNRS

 

Hello,
I am using a C code that scans VISA resources of type "ASRL[0-9]*::?*INSTR". This code works correctly on several computers, but on some, an error occurs:

VISA error in viFindRsrc: VI_ERROR_RSRC_NFOUND (Resource not found, check the search string).

However, in NI MAX, the resource is properly detected and works normally.
A strange behavior occurs: if I add a new VISA resource (for example, another serial port), the first resource starts being detected by my code, but not the second one.
In debug mode, the function viFindRsrc(hRM, "ASRL[0-9]*::?*INSTR", &findList, &numInstruments, desc); correctly finds the resource. However, when calling viFindNext(findList, desc);, an error occurs with the code -1073807343.

Best regards,

Frédéric BLANC LAAS-CNRS

 

int scan_port_VISA(void)
{

ViStatus status;
ViSession hRM, vi;
ViFindList findList;
ViUInt32 numInstruments;
ViChar desc[VI_FIND_BUFLEN];
char message_LOG[SERIAL_BUFFER];
char TXbuffer[SERIAL_BUFFER] = {0};
char RXbuffer[SERIAL_BUFFER] = {0};


status = viOpenDefaultRM(&hRM);
if (status != VI_SUCCESS)
{
save_LOG("Error opening default session");
return 1;
}
status = viFindRsrc (hRM, "ASRL[0-9]*::?*INSTR", &findList, &numInstruments, desc);
if (status != VI_SUCCESS)
{
save_LOG("Error creating search list");
viClose(hRM);
return 1;
}


Ctrl.com_count=0;
int exit=0;
while (!exit)
{
status = viFindNext(findList, desc);
switch (status)

....

 

0 Kudos
Message 1 of 3
(203 Views)

Good morning

 

I am not using visa to detect which coms (ASRL) are available.

instead i am using more simple fast & direct method that till this day always work

#include <windows.h>

int com_no ;

char str[128] ;

HANDLE hcom ;

 

for(com_no = 1 ; com_no <= 100 ; com_no++)
 {  
  sprintf(str , "\\\\.\\COM%d" , com_no) ;
  hcom = CreateFile(str , GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL);
  if(hcom != INVALID_HANDLE_VALUE)
 {
      sprintf(str , "ASRL%d::INSTR",com_no) ;
     //do somthing
    CloseHandle(hcom) ; hcom = NULL ;
}
 }
0 Kudos
Message 2 of 3
(149 Views)

bonjour

j'ai résolut mon problème, cela venais d'un problème électrique.

Avec un hub USB alimenté cela marche.

cordialement

Frédéric BLANC 

 

Hello

I solved my problem, it came from an electrical problem.

With a powered USB hub it works.

0 Kudos
Message 3 of 3
(141 Views)