How PC know if a Picaxe is conected?

Hello,

I realize a program .net, the choice of the port and the speed of transmission work. I would like to know if there is a means to know if a picaxe is connected well on the port.
My current solution is to send a byte towards the picaxe and this last one compares it, if the received byte is correct, then he sends back towards the pc another byte which will be analyzed by the program .net...
If I use a cable AXE 027 which system file must be analyzed?
If I use a "normal" serial cable, how to know if a Picaxe is in the other end? (This case isn't possible....?)

Thank you

technopengl
 

hippy

Ex-Staff (retired)
There's no easy option to tell if a PICAXE is connected if the PICAXE is executing a blocking command such as SERIN, SERRXD or IRIN without timeouts. The best you can do is have it respond as you are doing.

Checking for AXE027 presence will only tell you if the cable is present or not, checking for driver files will only tell you if an attempt has been made to install the driver, not even if it was successful.

The following procedure is probably best, assuming it isn't blocking ...

1) Check the COM port the AXE027 cable on can be opened
2) Close the COM port
3) Shell a command line PICAXE compiler to do a firmware check
4) Read and parse the response to look for the "PASS" response
5) Check the response matches what's expected

The shell command could for example be ...

"c:\Programming Files\Programming Editor\Compiler\picaxe08m2" -cCOM1 -f "c:\path\dummy.bas"
You can use any of the picaxe*.exe compilers to check the firmware of any PICAXE.

The -cCOM1 is changed to whichever COM port the AXE027 is on.

The c:\path\dummy.bas is a blank program which you can create before executing the shell and can delete afterwards. You will get a command syntax error if you don't specify a file.

For a list of command line options ...

"c:\Programming Files\Programming Editor\Compiler\picaxe08m2" -h
 

inglewoodpete

Senior Member
I use a "KeepAlive" function in VB.Net to determine that a PICAXE is connected.

A clock function in the VB.Net sends a (reserverd) character out the serial port on a regular basis (Ie. every few seconds). It also clears a flag to indicate that it is waiting for a response. The PICAXE I'm using is a 28x1 and uses background hSerial reception. The PICAXE code is structured as hippy suggests, above, so that it can never get "stuck" in a loop or blocking command. Whenever the PICAXE receives that reserved character, it echoes it back to the hSerial out pin.

Back at the VB.Net end of the serial link, the incoming serial handling routine sets a flag whenever it receives serial data (of any sort). Meanwhile, the timer function in VB.Net is monitoring for that echo flag to be set for every keepalive that it sends.
 
Last edited:
Thank you for your answers,

If I understood, the solution must be realized in two parts?
1. If a cable AXE027 is connected, the program has check the driver AXE027
2. If a normal cable is used, it is necessary to make Picaxe have a dialogue with the PC. This solution works, but requires in the beginning of program a "serin" with a timeout which waits for a character and for a "sertxd" which confirms that the good character was received. And a timer in vb.net?
I use a timer for this and a thread to read....

Hippy, I do not understand:
3) Shell has command line PICAXE to compile to doh has firmware check
4) Look for the " PASS " response Read and parse the response to
5) Check the response contests of expected what
How to realize one " Picaxe to compile " which check the "firmware"?

Inglewoodpete, I use one 28X1 and one 20X2, it seems to me that your method looks like what I made, no?

Thank you

Technopengl
 
I read the documentation and make some tests...
- Call the compiler
- Test the program
- Download the program
I don't want to test and\or to download the program...
Too bad not to be able to test only the port on which is connected the cable....

Only method is a dialogue between Picaxe and the program on the PC....

Thanks to you

technopengl
 

hippy

Ex-Staff (retired)
Too bad not to be able to test only the port on which is connected the cable....
I don't exactly understand how you mean; by using the -f switch you can perform a firmware check and nothing else. See example in post #3.
 
I return on this comment..
Thank you Hippy!
I didn't execute the command from my application, but tried to put the file "picaxe08.exe" and an emptie file " test.bas " in a called folder " firmware " placed on the desktop.
I typed in the console :
c:\Documents and Settings\Administrateur\Bureau\Firmware\picaxe08 -cCOMX -f test.bas
and I receive :
Firmware picaxe-08M2 v4.A
Now I have only to be able to send this command towards the file which will have to be in a place defined during the installation of the application and decode the message received by Picaxe.... It Is " Firmware picaxe-08M2 v4.A "? Sent in ASCII to sertxd??? Nonono...
Thank you technopengl
 
Top