RS232 / Serial Scale Help
Posted
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"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
Posted
Enthusiast

Code (gambas)
- RS232Scanner.EndOfLine = gb.mac
- Write #RS232Scanner, "S11\n"
- ' Wait for anything at all to be sent back.
- ' I'm not going to try and decipher the response message ATM until we can at least prove we got anything back.
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?)
Posted
Regular

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.
Posted
Enthusiast

1 guest and 0 members have just viewed this.




</IMG>