Issue with reading value from external devices
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Issue with reading value from external devices
I have been working with BCI2000 for the past two years to record EEG data while simultaneously controlling a robotic device. The system had been functioning well, and my code was running as expected. To control the robotic device, I transmit and receive data from an Arduino using a UDP connection. Specifically, I am reading EMG signals and motor encoder values.
However, after a recent system update, I reinstalled BCI2000 (version 3.6), and I am now unable to read values from the motor and EMG channels. Has anyone experienced a similar issue or have any suggestions for resolving this?
However, after a recent system update, I reinstalled BCI2000 (version 3.6), and I am now unable to read values from the motor and EMG channels. Has anyone experienced a similar issue or have any suggestions for resolving this?
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
From what you write, I understand that you wrote your own code to communicate with the Arduino. That code was integrated with BCI2000.
When you say that you reinstalled BCI2000 (in a newer version possibly), how did you migrate your modifications?
Maybe the system update is related to the issue? Could it be that you had firewall rules in place before the system update that allowed UDP packets to be read from the BCI2000 side, and that those rules got lost in the system update process?
When you say that you reinstalled BCI2000 (in a newer version possibly), how did you migrate your modifications?
Maybe the system update is related to the issue? Could it be that you had firewall rules in place before the system update that allowed UDP packets to be read from the BCI2000 side, and that those rules got lost in the system update process?
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
Thank you for your response. I have reviewed the firewall settings, and they remain unchanged since the last system update. The issue I am encountering is one-sided: when sending commands from BCI2000 to the external device via UDP, the values are transmitted correctly. However, when attempting to receive data from the external device to BCI2000 over the same UDP connection, the values are not read correctly. I have verified the output from the external device, which is transmitting the values accurately, but for some reason, BCI2000 is not able to read them properly.
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
There is no such thing as a UDP connection. UDP packets are sent from one socket to another independently, without establishing a connection.However, when attempting to receive data from the external device to BCI2000 over the same UDP connection, the values are not read correctly.
I can help you better if you could give a short outline of which BCI2000 components you are using, and how they communicate, and over which socket addresses.
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
I am sharing a portion of my code below for reference:
BEGIN_STATE_DEFINITIONS
"EMG1 12 0 0 0",
"EMG2 12 0 0 0",
"TENSION 12 0 0 0",
"ENCODER 16 0 0 0"
END_STATE_DEFINITIONS
GraspReleaseTask::DoPostFeedback(const GenericSignal&, bool& doProgress)
{
mLFingerPos =(State("ENCODER") - mMinEncoderValue) * (mpWindow->width() / 2 ) / (mMaxEncoderValue - mMinEncoderValue);
mFdsBarLength = 5 * State("EMG2") / mFdsMvc
}
And the corresponding .prm file settings are as follows:
Connector:ConnectorInput list ConnectorInputFilter= 1 *
Connector:ConnectorInput string ConnectorInputAddress= 192.168.137.1:20320
Please let me know if you need any additional parts of the code, I would be happy to share them.
BEGIN_STATE_DEFINITIONS
"EMG1 12 0 0 0",
"EMG2 12 0 0 0",
"TENSION 12 0 0 0",
"ENCODER 16 0 0 0"
END_STATE_DEFINITIONS
GraspReleaseTask::DoPostFeedback(const GenericSignal&, bool& doProgress)
{
mLFingerPos =(State("ENCODER") - mMinEncoderValue) * (mpWindow->width() / 2 ) / (mMaxEncoderValue - mMinEncoderValue);
mFdsBarLength = 5 * State("EMG2") / mFdsMvc
}
And the corresponding .prm file settings are as follows:
Connector:ConnectorInput list ConnectorInputFilter= 1 *
Connector:ConnectorInput string ConnectorInputAddress= 192.168.137.1:20320
Please let me know if you need any additional parts of the code, I would be happy to share them.
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
When I try to reproduce the issue locally, everything works as expected, so I don't think the code has been broken.
It would be useful for me to know the ConnectorOutputAddress and which IP address is the address of the Arduino, and which is that of the BCI2000 machine.
It would be useful for me to know the ConnectorOutputAddress and which IP address is the address of the Arduino, and which is that of the BCI2000 machine.
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
I am sharing a portion of my Arduino code below. I'm not certain whether it will be helpful, but it may provide some context regarding the issue.
IPAddress ip(192, 168, 137, 216);
unsigned int localPort = 8888;
unsigned int remotePort = 20320;
sprintf(ReplyBuffer, "EMG1 %d\n", EMG1);
Udp.beginPacket(Udp.remoteIP(), remotePort);
Udp.write(ReplyBuffer);
Udp.endPacket();
In this setup, I am attempting to send data from the Arduino and read it on the receiving end at IP address 192.168.137.216, port 20320.
Recently, I checked the active ports while running the BCI2000 application and did not find any activity on port 20320. I also verified the Windows firewall settings to ensure that this port was not being blocked, and no restrictions were found.
Based on these observations, my assumption is that the port might not be active on the receiving end, which could be why the values are not being read successfully. Could you suggest possible steps to activate or enable the port for successful communication?
IPAddress ip(192, 168, 137, 216);
unsigned int localPort = 8888;
unsigned int remotePort = 20320;
sprintf(ReplyBuffer, "EMG1 %d\n", EMG1);
Udp.beginPacket(Udp.remoteIP(), remotePort);
Udp.write(ReplyBuffer);
Udp.endPacket();
In this setup, I am attempting to send data from the Arduino and read it on the receiving end at IP address 192.168.137.216, port 20320.
Recently, I checked the active ports while running the BCI2000 application and did not find any activity on port 20320. I also verified the Windows firewall settings to ensure that this port was not being blocked, and no restrictions were found.
Based on these observations, my assumption is that the port might not be active on the receiving end, which could be why the values are not being read successfully. Could you suggest possible steps to activate or enable the port for successful communication?
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
From your code, I cannot see which remote IP you are using, but it should be the IP address of the BCI2000 machine.
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
I am using the remote IP address 192.168.137.1 with port 20320 and have specified the same in the .prm file as:
ConnectorInputAddress = 192.168.137.1:20320.
This setup was functioning correctly previously with the same specifications.
ConnectorInputAddress = 192.168.137.1:20320.
This setup was functioning correctly previously with the same specifications.
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
And 192.168.137.1 is your BCI2000 machine's IP address? I'm asking because .192.168.x.1 is a typical router address rather than a computer address.
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
For me, this is the IP address of the BCI2000 machine. I previously ran the experiment using the same IP address.
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
Did you reinstall BCI2000 from the same installer version as previously?
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
No, I installed the latest version of BCI2000 from the official repository (https://www.bci2000.org/svn/trunk), which is likely version 3.6.8.
-
mellinger
- Posts: 1341
- Joined: 12 Feb 2003, 11:06
Re: Issue with reading value from external devices
So you compiled it from source, using the latest version from the SVN repository? The latest verion on SVN does not have the ConnectorFilters any more, you would need to enable them in a CMake config file.
-
rroy2
- Posts: 8
- Joined: 10 Jul 2025, 16:02
Re: Issue with reading value from external devices
Could you please explain in a bit more detail what steps I need to follow in CMake? I am not very familiar with this procedure.
Who is online
Users browsing this forum: No registered users and 0 guests
