نمایش نتایج: از 1 به 10 از 58
Like Tree15 لایک

موضوع: ماژول ثبت امواج مغزی - سنسور EEG - ماژول NeuroSky Brainwave

Hybrid View

  1. #1
    Junior Member
    تاریخ عضویت
    Apr 2016
    نوشته ها
    7
    بله این کد رو آپلود کردم و start رو چاپ کرد فقط ، ولی با کد قبلی داده نمی ده
    مشکل از کجاست ؟

  2. #2
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    نقل قول نوشته اصلی توسط tolo.m نمایش پست ها
    بله این کد رو آپلود کردم و start رو چاپ کرد فقط ، ولی با کد قبلی داده نمی ده
    مشکل از کجاست ؟
    مکشلی که هست اینه که وارد شرط brain.update() نمیشه .
    تو فایل cpp رو که نگاه کنید میبیند کد نویسی این تابع این هست:
    کد:
    boolean Brain::update() {
    
    
        if (brainSerial->available()) {
            latestByte = brainSerial->read();
    
    
            // Build a packet if we know we're and not just listening for sync bytes.
            if (inPacket) {
            
                // First byte after the sync bytes is the length of the upcoming packet.
                if (packetIndex == 0) {
                    packetLength = latestByte;
    
    
                    // Catch error if packet is too long
                    if (packetLength > MAX_PACKET_LENGTH) {
                        // Packet exceeded max length
                        // Send an error
                        sprintf(latestError, "ERROR: Packet too long");
                        inPacket = false;
                    }
                }
                else if (packetIndex <= packetLength) {
                    // Run of the mill data bytes.
                    
                    // Print them here
    
    
                    // Store the byte in an array for parsing later.
                    packetData[packetIndex - 1] = latestByte;
    
    
                    // Keep building the checksum.
                    checksumAccumulator += latestByte;
                }
                else if (packetIndex > packetLength) {
                    // We're at the end of the data payload.
                    
                    // Check the checksum.
                    checksum = latestByte;
                    checksumAccumulator = 255 - checksumAccumulator;
    
    
                    // Do they match?
                    if (checksum == checksumAccumulator) {
    
    
                        // Parse the data. parsePacker() returns true if parsing succeeds.
                        if (parsePacket()) {
                            freshPacket = true;
                        }
                        else {
                            // Parsing failed, send an error.
                            sprintf(latestError, "ERROR: Could not parse");
                            // good place to print the packet if debugging
                        }
                    }
                    else {
                        // Checksum mismatch, send an error.
                        sprintf(latestError, "ERROR: Checksum");
                        // good place to print the packet if debugging
                    }
                    // End of packet
                    
                    // Reset, prep for next packet
                    inPacket = false;
                }
                
                packetIndex++;
            }
            
            // Look for the start of the packet
            if ((latestByte == 170) && (lastByte == 170) && !inPacket) {
                // Start of packet
                inPacket = true;
                packetIndex = 0;
                packetLength = 0; // Technically not necessarry.
                checksum = 0; // Technically not necessary.
                checksumAccumulator = 0;
                //clearPacket(); // Zeros the packet array, technically not necessarry.
                //clearEegPower(); // Zeros the EEG power. Necessary if hasPower turns false... better off on the gettter end?     
            }
            
            // Keep track of the last byte so we can find the sync byte pairs.
            lastByte = latestByte;
        }
        
        if(freshPacket) {
            freshPacket = false;
            return true;
        }
        else {
            return false;
        }
        
    }
    این کد رو مطالعه کنید و برای دیباگ قسمت به قسمتش یه چیزی مثل همون start رو سریال پرینت کنید ببینید به کدوم قسمت داره گیر میده که true بر نمیگردونه
    ویرایش توسط magmagmary : 08-20-2016 در ساعت 06:25 AM

کلمات کلیدی این موضوع

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO