Ive narrowed the problem down to the device call in the print_string
procedure. The print_string() procedure in print.jal:
procedure print_string(volatile byte out device, byte in str[]) is
var word len = count(str)
var byte i
for len using i loop
if (defined(print_string_terminator) == TRUE) then
if (str[i] == print_string_terminator) then
exit loop
end if
end if
device = str[i]
end loop
end procedure
Will work on my wife's Windows 8 laptop. It produces a string of garbage
characters on my laptop running Linux (Debian 7.0).
BUT, removing the volatile device variable and calling the usb_serial_data
variable directly like this:
procedure print_line(byte in str[]) is
var word len = count(str)
var byte i
for len using i loop
usb_serial_data = str[i]
end loop
usb_serial_data = "\r"
usb_serial_data = "\n"
end procedure
*does* work just fine on my laptop. I cannot figure out why this is.
FWIW, the print library procedure print_crlf() also works on my laptop when
passed usb_serial_data, but print_string() does not....
I've tested this both on a breadboard and a barebones circuit on a piece of
stripboard.
On Monday, July 28, 2014 6:24:43 AM UTC-5, Jim Gregory wrote:
>
> -- chip setup
> include 18f14k50
>
> -- target frequency to 48 MHz
> I am experiencing strange behavior with the print_string() function using
> usb_serial and an 18f14k50 and jalv2.4q and jallib version 1.0.0. With the
> following code:
>
> pragma target clock 48_000_000
>
> -- no fuses (use bootloader)
> pragma BOOTLOADER loader18 2048
> pragma fuses no
>
> const byte str_welcome[] = "Hi there"
> var byte i -- temporary variable
>
> forever loop
> -- poll the usb ISR function on a regular base, in order to
> -- serve the USB requests
> usb_serial_flush()
>
> -- check if USB device has been configured by the HOST
> if ( usb_cdc_line_status() != 0x00 ) then
> if !has_shown_welcome_msg then
> has_shown_welcome_msg = true
> print_string( usb_serial_data, str_welcome )
> print_crlf( usb_serial_data )
> end if
> else
> has_shown_welcome_msg = false
> end if
>
> -- check for input character
> if usb_serial_read( ch ) then
> -- echo input character
> usb_serial_data = ">"
> usb_serial_data = ch
> print_crlf( usb_serial_data )
> i print_string( usb_serial_data, str_welcome )
> print_crlf( usb_serial_data )
> blink_led(green)
> end if
> end if
>
> Under Linux, it prints 3 unprintable characters when a serial connection
> is established and each time a key is pressed. Under Windows 8, it prints
> the correct string.
>
> If I replace the print_string() function calls by explicitly looping
> through the array, i.e.:
>
> ;print_string( usb_serial_data, str_welcome )
> for 8 using i loop
> usb_serial_data = str_welcome[i]
> end loop
>
> The string prints normally on both Linux and Windows 8.
>
> Furthermore, if I close the serial terminal and try to re-establish a
> connection under either Linux or Windows, I can't reconnect regardless of
> which code I use. Under Linux, I receive the error message:
>
> tty_port_close_start: tty->count = 1 port count = 0.
>
> It won't reconnect without manually resetting the 18f14k50.
>
> I suspect the two problems are related, but am not sure....:(
>
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.