RS232 / Serial Scale Help

Post

Posted
Rating:
#26
Avatar
Regular
thatbruce is in the usergroup ‘Regular’

AndyGable said


<IMG src="https://support.algpos.co.uk/images_help/barcodeReader-incoming.png"> </IMG>
this is just to show you I am getting data from the scanner side (so the scanner/scale is communicating to the Computer)

No, AFAICT it tells me that you are getting data from the scanner unit and not particularly the scanner and the scale.
Get this manual https://manualzz.com/download/1055726 if you dont already have it and go through section 5, scanning each of the relevant looking barcodes, IOW lets find out if the damn scale unit is actually working. In fact it might be good idea to go through the entire bloody manual.

Ok, that's enough of the hardware for a moment.



Back to the software!

First lets get rid of this one: (I'm only writing this to make sure we are operating on the same wavelength here.)'

Code

   Write #RS232Scanner, "S11\n"
   Write #RS232Scanner, "S14\n"
is equivalent to "Hey scale, whats the weight? NO STOP DOING THAT and do a 4!" (Whatever a 4 is, its not in any Datalogic "manual" that I can find.)

Anyway, lets try this way. This time I just want to wait till anything at all is received back from the unit.

Code

Public Sub btnRequestWeight_Click()

    Dim iBytes as Integer
    Dim sWhatever as String
    
    RS232Scanner.EndOfLine = gb.mac
    RS232Scanner.Blocking = True
     
    Write #RS232Scanner, "S11\n"
       
    ' Wait for anything at all to be sent back.
   Do
      Wait 0.001                           ' Using a really small delay this time to lessen overflow risk
      sWhatever &= Read #RS232Scanner As Byte       ' I hope this works, I've not tried appending bytes to a string "buffer" before.
      Print "Got ";Len(sWhatever);"from scanner"         ' Just output the length of the receiving buffer
   Loop Until #RS232Scanner.Eof                  ' Keep going until we get an eof char. YOU MAY HAVE TO KILL IT AGAIN HERE.
 
     ' I'm not going to try and decipher the response message ATM until we can at least prove we got anything back.
 
 End

Online now: No Back to the top

Post

Posted
Rating:
#27
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

Code (gambas)

  1. Public Sub btnRequestWeight_Click()
  2.  
  3.     Dim iBytes as Integer
  4.     Dim sWhatever as String
  5.    
  6.     RS232Scanner.EndOfLine = gb.mac
  7.     RS232Scanner.Blocking = True
  8.      
  9.     Write #RS232Scanner, "S11\n"
  10.        
  11.     ' Wait for anything at all to be sent back.
  12.         Do
  13.                 Wait 0.001                                                                      ' Using a really small delay this time to lessen overflow risk
  14.                 sWhatever &= Read #RS232Scanner As Byte                 ' I hope this works, I've not tried appending bytes to a string "buffer" before.
  15.                 Print "Got ";Len(sWhatever);"from scanner"                      ' Just output the length of the receiving buffer
  16.         Loop Until #RS232Scanner.Eof                                            ' Keep going until we get an eof char. YOU MAY HAVE TO KILL IT AGAIN HERE.
  17.  
  18.      ' I'm not going to try and decipher the response message ATM until we can at least prove we got anything back.
  19.  
  20.  End
  21.  

I am sorry to say not a thing on that code either :(

I even tried to send a simple "S334\n" command (should make the scanner just bleep) but eben that did not work.

COULD all this issues be becuase I am opening as incoming only? (like from device to Computer and no both way communcation or is 2way the default for the comport in gambas?)
Online now: No Back to the top

Post

Posted
Rating:
#28
Avatar
Regular
thatbruce is in the usergroup ‘Regular’
:evil:
I even tried to send a simple "S334\n" command (should make the scanner just bleep) but eben that did not work.

COULD all this issues be becuase I am opening as incoming only? (like from device to Computer and no both way communcation or is 2way the default for the comport in gambas?)


I don't know why the Write's didn't raise an error, but if you don't open FOR READ WRITE then nothing should be sent, so nothing could happen. There will be silence … and by the way it's not the comport your code is talking to, its the gambas runtime and then some shared libraries and then the operating system and only then the com port (UART). IOW gambas has no concept of a comms port only a stream.

Online now: No Back to the top

Post

Posted
Rating:
#29
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
I'm using

Code (gambas)

  1. RS232Scanner.open
  2.  

Do I need to do it like

Code (gambas)

  1. open RS232Scanner for read write
  2.  
Online now: No Back to the top
1 guest and 0 members have just viewed this.