Problem with serinp$

Problem with serinp$

Postby umineral » Wed Sep 17, 2014 9:51 am

I need a serial input on RX (pin 37) and output to TX (pin 36) just like "INPUT" and "PRINT" works on the USB port 0. I have tried the below code but it just falls thru with out any string or characters being received. The input to serinp$ could come at any time.

command$ = "" ' null command variable
serinit 1,9600,8,1,0 ' Init port
command$ = serinp$(1,20,13,1) ' Input string with max characters = 20, stop on CR, ?
error = serout(1,command$)
Now test for valid command. ' It never gets a valid command or any character, just falls thru the serinp$.

Is there something wrong with what I'm expecting from the code or how it is being used? I believe that signals are being sent into the hardware pin 36.
Posts: 3
Joined: Mon Jul 14, 2014 12:59 pm

Re: Problem with serinp$

Postby Daniel » Wed Sep 17, 2014 10:40 am


You seem to have an awfully short time set for the 'timeout' parameter. The syntax is <instring>=SERINP$(<port #>,<numchars>,<endchar>,<timeout>) and a value of 50000 for timeout will have the function pause for a second waiting for the character. Try using command$ = serinp$(1,20,13,1000000) and see if you have the desired behavior.

Since you say that the input may come at any time, you would normally use a smaller value for 'timeout' and then the function will return the characters allready in the buffer. You would then need to process the buffer to detect the 'CR'.

Posts: 91
Joined: Tue Nov 13, 2012 2:10 pm

Return to EzSBC1

Who is online

Users browsing this forum: No registered users and 1 guest