Can you be more specific? Do you mean Bluetooth or a Bluetooth device that mimics an rs232 serial port. Liberty can deal with the latter. There are plenty examples on the LBPE discussing serial port handling. Perhaps if you gave us the name of the device and message examples you would get better help.
Essentially you keep polling the serial port using a timer to see if there is anything in the buffer, if so act on it or wait for the next poll. Its relatively simple to do but too wide ranging a subject to offer code examples.
Hi All, Not sure if this is the right place to ask but here goes. I have an old CNC lathe which is currently controlled by DOS software. It works well but the software is a bit slow and tedious to use.
The lathe is controlled using RS323 and I have a list of its control codes. I wrote a simple GUI interface in LB to send these controls to the lathe. When the programme is run and the relevant GUI button pressed the lathe does as requested. If the same button is again pressed nothing happens unless you switch the lathe on an off. It will then do exactly the same, ie receive one message and the lock up.
I know that the lathe sends ASCII codes 13 10 17 when it has received a message but as a new coder I don't know how to get the programme to wait for this reply before moving on.
I am not entirely sure that this is the only problem but at least its a start.
'It is recommended that you set certain handshaking switches 'so that your program doesn't just freeze when waiting for 'data to come in or trying to send data. 'To do this, we add ds0, cs0, and rs switches as below.
open "COM2:9600,n,7,1,ds0,cs0,rs" for random as #comm
Given it handles the first command I am pretty sure it is just handshaking giving you problems.
I tried modifying the line as you suggested but unfortunately the lathe did exactly the same thing, worked once then locked up.
When I was originally trying the lathe on LB I used the TERMINAL programme in the samples directory.
If I typed park-x into the (kb)box then pressed return a small square appeared after the typed words and the lathe homed the x axis. when the axis had reached the home position the a further small square appeared on the next line.
If I the typed park-z into the (kb)box then pressed return a small square appeared after the typed words and the lathe homed the z axis. when the axis had reached the home position the a further small square appeared on the next line.
You could then enter any of the other lathe codes and it would respond when you pressed return.
I have assumed that the small squares are ASCII characters.
Yes ASC characters, unprintable ones. What you need to do is play with the terminal software again. You need to properly understand the conversation you are having with the lathe character by character.
When you get a message back from the lathe it will be stored in a string say a$, now instead of printing a$ what you need to do is find the length of a$ with l=len(a$) then character by character find the ASC values. Use print asc(mid$(a$,1,1)), print asc(mid$(a$,2,1)), print asc(mid$(a$,3,1)) etc right up to the full length of the string you obtained with l=len(a$)
Now you will have the full message and you will know what these hidden characters are. It sounds like you have to wait on the lathe responding prior to sending your next command. It may just be a timing issue.
Also, Liberty always adds a CRLF pair to sent text. To stop that you end your text with a ; that suppresses the CRLF. Your lathe may well ignore these two additional characters but it might be confusing it. Try messaging with and without a trailing ;