LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

display unPrintable char ascii

hello,
i'm gething string from a bar-code, the bar code is program that at end of the string i'm puting a ctrl-g(^G) and enter.
CTRL-G in ascii table is 07. how can i check if i get the CTRL-G(^G) and the enter at the end of the string.?
 
regard's
eyal.
0 Kudos
Message 1 of 9
(4,516 Views)
Hi!

   I suppose your program returns CHAR data type. If so, you only have to cast characters to integers, and display the integer number corrseponding to the char variable.

   char input;
   int myInt;
 
    .....

    input = getFromBarCode();
    myInt = (int)input;   //explicit cast, here, not compulsory...

   Otherways, you can get informations on char data type through some ansi C functions.  In ansi C library, select "character handling", and then "Character testing".  There you find some useful functions to tell you if you are getting a control char, and so on...

   Is quite silly as answer, but... I hope it helps! Have a nice day!

graziano

0 Kudos
Message 2 of 9
(4,507 Views)

I presume you are just wanting to sanity check this once or twice vs. every instance.....

You can run thedebugger.

Break after receiving the data.  Highlight the variable and hit (shift + F7) to view the variable value.

That pops up a window with the value.  change the format (from the command toolbar) to hex and you will see all.

 

==>Scott

0 Kudos
Message 3 of 9
(4,499 Views)

it's a dll for labview.

i'm reading the barcode into standart i/o.

but i'm still cant see the ascii chars.

here is my code :

int i,z;
   char j,ch=0;
    scanf("%s",input); 

  for (i=0;i<strlen(input);i++)
  {
       ch=input[i];
       z = (int)ch;
   if(z==7)
    {
     printf("\n ctrl-g exsit\n");
    }
     else
     {
      printf("\nctrl-g not exsit\n");
    }
     
 }
   output=input;
 
 
}

0 Kudos
Message 4 of 9
(4,495 Views)
Hi!

   Maybe the problem is scanf() function!   I think the problem is when you try to read the standard input and format it into a string (%s).  This way, the standard input is interpreted, and special characters cannot go into the string....  Moreover, a '\0' char is considered the end of the string, so you can't merge ascii data and strings.  (in LabVIEW, is not like this, you can wire a U8 array to a "byte array to string", and you get a string with special characters too!)

   You have to handle the input as an array of chars, and not put it into a string.
   
   Try something like:   read(stdin, input, number_of_Bytes_to_read);

   (or try with getchar() )

   I'm not shure about my post, just try and let me know if you solved!!  Have a nice day!

graziano
0 Kudos
Message 5 of 9
(4,478 Views)
Hi, graziano
i try it in labview but it's not working there, becuse of that i'm trying to wirte a dll in cvi to solve the problem
if you have any vi just send it and i will chek it, and if it's work i'll will send you a beer :).
i will replce the scanf() and let you now if it's working.
try this link in labview forum :
 
regard's
eyal.
0 Kudos
Message 6 of 9
(4,475 Views)
Hi Eyal!

   In LabVIEW  I have an array of unsigned 8 bit, I convert it to string, and send it via RS232, this works.  Maybe you have to do the opposite.  I suppose you may use VISA functions to read from a serial port (say...), and then you can convert the read string into U8 (I do this in the client application).
  
   Anyway, can you provide more details on:

    - how are you getting data (wich port.....);
    - what's the VI you use for read data;

   Let me know!

   I'm in Italy, and here it's 18.30! I'll be back tomorrow, and try to check....  have a good evening!

graziano
   
0 Kudos
Message 7 of 9
(4,472 Views)
Hi  graziano,
I'm not using any visa, becuse the barcode is connected via the keybord input.
In labview the combination of CTRL+G[i think]  is shortcut to change working mode/run/edit
I'm using labview 7.1
 
regard's
eyal.
0 Kudos
Message 8 of 9
(4,465 Views)
Hi!
   I understand! It's not easy, because (I suppose) the operating system filters the characters read from PS2 port, and re-maps it as char.   I'm not shure, but using read() c-function you should be able to acquire the right char (but sorry, I can't reproduceit....). I'm trying now, to test getchar(), I will let you know....

  Have a nice day!

graziano
0 Kudos
Message 9 of 9
(4,452 Views)