Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:20 04 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Device SerialTx problem

Author Message
circuit
Senior Member

Joined: 10/01/2016
Location: United Kingdom
Posts: 231
Posted: 09:28pm 20 Apr 2024
Copy link to clipboard 
Print this post

This works infallibly; the code on the receiving PicoMite being:

'Picomite Simple Serial Client

Option AUTORUN ON
Dim string cmd

SetPin GP1,GP0,com1 'Set up comms channel 1
Open "com1:19200, 256, ActionCommand, 3" As #1

Do
WatchDog 500        'This recovers from errors not ignored but resets the chip
Loop

Sub ActionCommand   'Message receipt detected
On ERROR IGNORE     'This avoids system reset if duff command arrives
 Pause 30          'ensure all characters in command have arrived
 Line Input #1,cmd 'Get the command
 Execute cmd       'Action the received command

End Sub             'Return from the interrupt


and the sending device;
SetPin GP1,GP0,com1 ' SetPin GP1,uart1 Rx: SetPin GP0,uart0 Tx
Open "com1:19200, 256" As #1 '

and then type directly

print #1,"option heartbeat on"

print #1,"option heartbeat off"


The heartbeat LED switches perfectly, as do all other output pins when configured and set.  

But if I reset the sending device (killing the serial port) and then code;

Device SerialTx GP0, 19200, "option heartbeat on"


the same receiving device crashes.  So, thinking I might need a CR + LF I tried;

Device SerialTx GP0, 19200, "option heartbeat on" +chr$13 +chr$10


but again, the receiving device crashes.  

Dear friends, where might I be going wrong?
Edited 2024-04-21 07:31 by circuit
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1793
Posted: 09:58pm 20 Apr 2024
Copy link to clipboard 
Print this post

Another thing to try (untested):-
OPTION ESCAPE : Message$ = "option heartbeat on \n" : Device SerialTx GP0, 19200, Message$
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5912
Posted: 10:01pm 20 Apr 2024
Copy link to clipboard 
Print this post

Start by increasing the watchdog timeout and the pause.
Edited 2024-04-21 08:05 by TassyJim
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5912
Posted: 11:47pm 20 Apr 2024
Copy link to clipboard 
Print this post

Another thought bubble.
Can the Device SerialTx command be used from the commandline or does it get cut short when you return to the command prompt?

Easy to test by using INPUT instead of LINE INPUT

Jim
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5912
Posted: 03:36am 21 Apr 2024
Copy link to clipboard 
Print this post

Something I should have spotted sooner.
You are missing the brackets in chr$(13) and chr$(10)

If that fails, try putting the DEVICE command in a short program instead of commandline.
VK7JH
MMedit   MMBasic Help
 
circuit
Senior Member

Joined: 10/01/2016
Location: United Kingdom
Posts: 231
Posted: 05:38am 21 Apr 2024
Copy link to clipboard 
Print this post

  TassyJim said  Something I should have spotted sooner.
You are missing the brackets in chr$(13) and chr$(10)


Sorry, in fact when I was typing in the "real world" I did have the brackets - it was only when I was typing into this appeal for help late at night that I missed the brackets out.  Sorry to mislead.  

Only just getting up in the morning here in the UK and I have a busy day in uniform with Royal Duties after which I will probably be too tired to get back to the computer.  Back soonest to try out your suggestions; thank you.
 
circuit
Senior Member

Joined: 10/01/2016
Location: United Kingdom
Posts: 231
Posted: 08:05am 21 Apr 2024
Copy link to clipboard 
Print this post

Jim, I had a few minutes spare after getting my uniform on (it takes quite a while to dress properly; full thing with sword etc. -sword slings are a pain in the neck!) so I switched on the computer and considered your first note about the timeout and pause.  I simply upped the speed to 115200 on both units and hey presto, all is working!  It is amazing the peace of mind that results; I can now concentrate on the day's duties without thinking around in the back of mind about what I was getting wrong in the programming!  And yes, it works just fine from the command line.  What a benefit it is to have friends in Australia working things out for you whilst you sleep.  Many thanks.
Edited 2024-04-21 18:06 by circuit
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3017
Posted: 02:04pm 21 Apr 2024
Copy link to clipboard 
Print this post

I also found that I was getting failures (dropped characters) at a lower baud rate, and all worked perfectly when I upped back to 115200.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
circuit
Senior Member

Joined: 10/01/2016
Location: United Kingdom
Posts: 231
Posted: 08:25pm 21 Apr 2024
Copy link to clipboard 
Print this post

  lizby said  I also found that I was getting failures (dropped characters) at a lower baud rate, and all worked perfectly when I upped back to 115200.


It is always most reassuring to receive such a confirmation from a colleague, thank you for this feedback. Yes, 115200 appears to counter any time-out issues.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024