View unanswered posts | View active topics It is currently Thu Sep 09, 2010 4:26 am



Post new topic Reply to topic  [ 6 posts ] 
(+ newLISP Windows RS232) 
Author Message

Joined: Sun Sep 27, 2009 12:08 am
Posts: 65
Location: Russia
Post (+ newLISP Windows RS232)
I need to communicate with standart rs-232 serial port on PC.

Is it possible to write on newLISP something like (read-port "COM1" 20)?


Sun Mar 07, 2010 6:47 pm
Profile

Joined: Sun Dec 02, 2007 5:10 pm
Posts: 386
Location: Florida
Post Re: (+ newLISP Windows RS232)
Couldn't you use the "import" function to import the necessary C functions from some windows DLL?

_________________
Get your Objective newLISP groove on.


Tue Mar 09, 2010 1:40 am
Profile WWW

Joined: Sun Sep 27, 2009 12:08 am
Posts: 65
Location: Russia
Post Re: (+ newLISP Windows RS232)
itistoday wrote:
Couldn't you use the "import" function to import the necessary C functions from some windows DLL?


Well, I’ll try. I’m not too familiar with C, but it is a good reason to learn it closer.


Tue Mar 09, 2010 4:27 am
Profile

Joined: Tue Oct 27, 2009 9:01 pm
Posts: 10
Location: Croatia
Post Re: (+ newLISP Windows RS232)
Hi Fritz,
do you have same success in writing to serial port?
I also would like to talk to uC with forth on board via serial port from Linux.
I didn't jet try, maybe this weekend....


Fri May 28, 2010 8:53 am
Profile E-mail

Joined: Sun Sep 27, 2009 12:08 am
Posts: 65
Location: Russia
Post Re: (+ newLISP Windows RS232)
Robert Gorenc wrote:
do you have same success in writing to serial port?


Yep. Here is a part of working code (Windows PC):

Code:
; Initialization
(define (scales-init)
  (exec "mode COM1 BAUD=9600 PARITY=N DATA=8 STOP=1"))

; Getting data from COM-port
(define (scales-weight-up)
  (local (hndl buff)
    (set 'hndl (open "COM1" "r"))
    (read hndl buff 40 (char 0x0D))
    (close hndl)
    (int (-12 5 buff))))

(scales-init)

; Measuring
(if (catch (scales-weight-up) 'result)
  (println "Weight: " result)
  (println "No link."))


Fri May 28, 2010 9:42 am
Profile

Joined: Tue Oct 27, 2009 9:01 pm
Posts: 10
Location: Croatia
Post Re: (+ newLISP Windows RS232)
thanx,
something similar was my idea, but I need read and write access, so my doubt is open two pipes, one for reading and one for writing, or one with r/w......
something like:
(set 'hin (open "/dev/ttyUSB0" "r"))
(read hin buff 40)
(close hin)
and
(set 'hout (open "/dev/ttyUSB0" "w"))
(write-buffer hin buff )
(close hout)

or
(set 'hndl (open "/dev/ttyUSB0" "u"))
(write-buffer hndl buff)
(read hndl buff 40)
(close hndl))

I will try what is better working for me.
(exit)


Fri May 28, 2010 10:47 am
Profile E-mail
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.