Shop OBEX P1 Docs P2 Docs Learn Events
Problem with method not being called — Parallax Forums

Problem with method not being called

ElkinElkin Posts: 58
edited 2011-05-03 13:29 in Propeller 1
I have a main method "Version 1.6" which is calling another method "SD_log" to write ADC values to an SD card. When the SD_log is run by itself with all lines active (no apostrophes) the method will come up on the PST as it should and when the SD card is checked through a card reader it functions correctly.

When the SD_log method is called through the "Version 1.6" method the PST logs the ADC prep and ADC running strings correctly but when I try to read the card there is no file.

I have a couple ideas of what the problem could be but I am not sure. First in the "SD_log" program lines 86 and lines 127 are used to start and stop the logging period and this needs to be done if there is not a finite number on the repeat block for writing to the SD card.

Also "SD_log" will not work correctly if term.start (line 79) is active when I run it from the main program.

The problem must be in calling "SD_log" from "Version 1.6" I do need to figure out a way as well to close the log file (line 133) and unmount (line 139) the ADC before I can read the SD card.

This program will not be connected to a computer when it is running so it is not possible to have the data read out on the PST only.

Let me know if you need to see any of the other methods.

Cheers!

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-05-03 12:08
    You can't share fullduplexserial this way! Either you use it in Version 1.6 or you use it in SD_log. In other words: you can't start it in Version 1.6 and call it in SD_log.

    In fact both term objects are different where only one is initialized. The uninitialized term (in SD_log) causes the problems. When the TX buffer is full, (which will overwrite other memory) it will wait until the TX buffer is send. But this does not happen, as the term is not initialized, so it's waiting forever - no more SD card logging, no more ADC.

    PS:
    If you want to use the same fullduplexserial you have to tweak it. Move all VARs to the DAT section. Then it's fine to initialize it once and use it in different objects. BUT ... as both programs (the main of Version 1.6 and the main of SD_log) use it anytime they want you need a way to synchronize all the term functions.
  • ElkinElkin Posts: 58
    edited 2011-05-03 12:28
    So you are saying that if I remove the FullDuplex Serial completely from SD_log then it will function normally? That seems like too simple of a solution. Must I then export lines 133 and 139 (sdcard.pclose and sdcard.unmount) to version 1.6 in order to stop the SD card and be able to retrieve the data?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-05-03 12:40
    Yep, removing fullduplexserial completely from SD_log could fix the problem.

    If you want to use FSRW in Version 1.6 as well (for reading) you have the same problem as with fullduplexserial. You have 2 different versions of FSRW running in different objects.

    I think the easiest way is to move the code from SD_log into version 1.6.
  • ElkinElkin Posts: 58
    edited 2011-05-03 12:51
    I agree I think that would be easier... I suppose there isnt that much code anyhow. I appreciate the help!
  • ElkinElkin Posts: 58
    edited 2011-05-03 13:16
    Is there a fairly straightforward way to do this without using a pub method to do so? Because the pub method would sit right in the middle of my main program and the repeat block would not let the program go further. Is there a way to start that portion and then move on, perhaps with a IF ELSE function or do I need to call a new cog again?
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-05-03 13:29
    It's already started in it's own COG.

    You only have to
    1. rename main from SD_log to for example sd_main
    2. copy the whole code from SD_log to Version 1.6
    3. Instead of COGNEW( SD_ADC, ... ) you do a COGNEW( sd_main, ... )
Sign In or Register to comment.