Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting duplicate data after closing and opening the port #109

Open
poisa opened this issue Sep 8, 2016 · 1 comment
Open

Getting duplicate data after closing and opening the port #109

poisa opened this issue Sep 8, 2016 · 1 comment
Assignees
Labels

Comments

@poisa
Copy link

poisa commented Sep 8, 2016

Hey, I'm really sorry for the noise as I'm sure this is completely user error (demo project works fine) but I'm having a strange issue and you're probably going to know what's wrong right away.

The first time I open the port it works fine but if I close it and open it again I'm getting double the data. If I do this again, I get triple data, etc, etc. Almost as if a callback is being set over and over again but never unset. I can't seem to find where this happens in my code.

This is how I'm opening the port:

    @IBAction func recordToggle(sender: AnyObject) {

        guard let port = serialPort else {
            return
        }
        let descriptor = ORSSerialPacketDescriptor(prefixString: "{", suffixString: "}", maximumPacketLength: 150, userInfo: nil)

        switch recordButton.state {
        case NSOffState:
            print("Closing serial port \(port)")
            port.stopListeningForPacketsMatchingDescriptor(descriptor)
            port.close()

        case NSOnState:
            print("Opening serial port \(port)")
            port.startListeningForPacketsMatchingDescriptor(descriptor)
            port.open()

        default:
            break
        }
    }
@armadsen armadsen self-assigned this Dec 12, 2016
@armadsen armadsen added the bug label Dec 12, 2016
@haoyuant
Copy link

same issue here, any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants