Serial Port. Com1 communication
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Serial Port. Com1 communication
I would like to send some hexadecimal codes to a vending machine via the com port.
Does anyone have the syntax needed to do this?
So far what I have:
on MouseUp
open driver "COM1:"
<----- what goes in here to send the codes
close driver "COM1:"
end mouseUp
Any guidance would be deeply appreciated.
Does anyone have the syntax needed to do this?
So far what I have:
on MouseUp
open driver "COM1:"
<----- what goes in here to send the codes
close driver "COM1:"
end mouseUp
Any guidance would be deeply appreciated.
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Serial Port. Com1 communication
Treat it as a file and use the write command.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Serial Port. Com1 communication
Okay, I have been trying. This is what I have so far:
I think it should be working, but it is not.
Any more guidance?
on mouseUp
set the serialControlString to BAUD=38400, PARITY=N, DATA=8, STOP=1
open driver "Com1:" for binary write
write (0xFE, 0x08) to driver "Com1:"
end mouseUp
I think it should be working, but it is not.
Any more guidance?
on mouseUp
set the serialControlString to BAUD=38400, PARITY=N, DATA=8, STOP=1
open driver "Com1:" for binary write
write (0xFE, 0x08) to driver "Com1:"
end mouseUp
Re: Serial Port. Com1 communication
Hi Eric,
some formal issues:
1. put QUOTES around strings!
...
set the serialControlString to "BAUD=38400, PARITY=N, DATA=8, STOP=1"
...
write "0xFE, 0x08" to driver "COM1:"
...
2. Check THE RESULT after opening the driver!
It will give you some info if and what might go wrong:
Best
Klaus
some formal issues:
1. put QUOTES around strings!
...
set the serialControlString to "BAUD=38400, PARITY=N, DATA=8, STOP=1"
...
write "0xFE, 0x08" to driver "COM1:"
...
2. Check THE RESULT after opening the driver!
It will give you some info if and what might go wrong:
Code: Select all
...
## The dictionary uses capitals COM1, maybe that matters, too?
open driver "COM1:" for binary write
if the result <> EMPTY then
anwer "ERROR:" && the result
## No need to proceed!
exit to top
end if
...
Klaus
Re: Serial Port. Com1 communication
Thank you so much for your response, I really appreciate it.
Went ahead and changed the code to:
on mouseUp
set the serialControlString to "BAUD=38400, PARITY=N, DATA=8, STOP=1"
open driver "COM1:" for binary write
write (0xFE, 0x08) to driver "COM1:"
end mouseUp
but it still did not work, it seems to behave like if the port was not open.
Any ideas?
Went ahead and changed the code to:
on mouseUp
set the serialControlString to "BAUD=38400, PARITY=N, DATA=8, STOP=1"
open driver "COM1:" for binary write
write (0xFE, 0x08) to driver "COM1:"
end mouseUp
but it still did not work, it seems to behave like if the port was not open.
Any ideas?
Re: Serial Port. Com1 communication
I may repeat mayself, but use QUOTES around strings:
...
write "0xFE, 0x08" to driver "COM1:"
...
and check the result!
...
write "0xFE, 0x08" to driver "COM1:"
...
and check the result!
Re: Serial Port. Com1 communication
Sorry I missed that, but in all the tutorials I have read it has the content after the write command within parenthesis.
Made the change to:
on mouseUp
set the serialControlString to "BAUD=38400, PARITY=N, DATA=8, STOP=1"
open driver "COM1:" for binary update
write "0xFE, 0x08" to driver "COM1:"
end mouseUp
Still nothing.
I know all my connections are good, because if I send the command from Pololu Serial Transmitter it works.
I know this is something simple, but being a neophyte I must be missing it.
Made the change to:
on mouseUp
set the serialControlString to "BAUD=38400, PARITY=N, DATA=8, STOP=1"
open driver "COM1:" for binary update
write "0xFE, 0x08" to driver "COM1:"
end mouseUp
Still nothing.
I know all my connections are good, because if I send the command from Pololu Serial Transmitter it works.
I know this is something simple, but being a neophyte I must be missing it.
Re: Serial Port. Com1 communication
Serial communication is not dead, someone should have the answer. . .
Anybody out there?
Anybody out there?
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Serial Port. Com1 communication
I'd check this stack out
http://quality.runrev.com/show_bug.cgi?id=12545
Note there may still be a bug in LC 7.x but it seems they are getting it to work in 6.x
Simon
http://quality.runrev.com/show_bug.cgi?id=12545
Note there may still be a bug in LC 7.x but it seems they are getting it to work in 6.x
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Serial Port. Com1 communication
Thank you Jacque, Klaus and Simon for trying to help me. This is so frustrating, I feel this is something simple to do, but for some reason it is just not working.
Went ahead and installed version 6, but that did not do it either.
I have a feeling that the code I came up with is not opening the port. What do you think?
If you get any other ideas, please let me know. Again THANK YOU so very much for your time and caring enough to help.
Eric
Went ahead and installed version 6, but that did not do it either.
I have a feeling that the code I came up with is not opening the port. What do you think?
If you get any other ideas, please let me know. Again THANK YOU so very much for your time and caring enough to help.
Eric
Re: Serial Port. Com1 communication
Hi Eric,
did I mention to check "the result" already?
might give a least a tiny hint.
Best
Klaus
did I mention to check "the result" already?
Code: Select all
...
## The dictionary uses capitals COM1, maybe that matters, too?
open driver "COM1:" for binary write
if the result <> EMPTY then
anwer "ERROR:" && the result
## No need to proceed!
exit to top
end if
...
Best
Klaus
Re: Serial Port. Com1 communication
Actually, I installed version 6 and using this code:
on mouseUp
set the serialControlString to BAUD=38400, PARITY=N, DATA=8, STOP=1
open file COM1 for binary write
write "0xFE, 0x08" to file COM1
close file COM1
end mouseUp
With the above code I can at least see that the board I am trying to address gets a signal, by that I mean that I see communication. I think now it is a matter of sending the right hexadecimal command.
write "0xFE, 0x08" may not be correct. I don't know, but I am getting closer, I am seeing the diodes light up.
I also don't know what you mean by check the result other that it did not work.
on mouseUp
set the serialControlString to BAUD=38400, PARITY=N, DATA=8, STOP=1
open file COM1 for binary write
write "0xFE, 0x08" to file COM1
close file COM1
end mouseUp
With the above code I can at least see that the board I am trying to address gets a signal, by that I mean that I see communication. I think now it is a matter of sending the right hexadecimal command.
write "0xFE, 0x08" may not be correct. I don't know, but I am getting closer, I am seeing the diodes light up.
I also don't know what you mean by check the result other that it did not work.
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Serial Port. Com1 communication
Hi CPSEric,
Before Klaus blows a gasket please look up "result" in the dictionary. You'll use it lots of times to help solve problems, it gives you messages as to possible problems.
Most of the time it's empty which means the last procedure worked.
Simon
Before Klaus blows a gasket please look up "result" in the dictionary. You'll use it lots of times to help solve problems, it gives you messages as to possible problems.
Most of the time it's empty which means the last procedure worked.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Serial Port. Com1 communication
Ommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm...
Thank you, Simon!
Thank you, Simon!
Re: Serial Port. Com1 communication
I like what Simon says.
But please, let us not blow any gaskets. Klaus thank you too.
Is it Klaus Major? Have I not seen your name in several websites browsing for an answer to my dilemma?
Thank you all.
But please, let us not blow any gaskets. Klaus thank you too.
Is it Klaus Major? Have I not seen your name in several websites browsing for an answer to my dilemma?
Thank you all.