-
Notifications
You must be signed in to change notification settings - Fork 39
Problem with sending a few messages in a row with different lengths #61
Comments
@Ahmadreza-Shahrokhshahi I don't think this project or nanomsg itself are actively maintained. I'm also not involved, but I just wanted to respond in case nobody else does. |
@mayfield Thanks for your response. I was wondering if you could come up with some ideas. I can see that there is a function of I am trying to clear the |
I'm not familiar with `ffi.new`, but I wouldn't be surprised if there were
a lot of complicated library interop issues with that technique, doubly so
on python2. If you're on python3, I'd probably just send it `"my
data".encode()` as the `data` argument and see if that helps.
|
I'm using python3. The other problem is that the file |
Hi @djc @mayfield @bnewbold
I am using
nnpy
to connect to my robot. It is at the following format:push = nnpy.Socket(nnpy.AF_SP, nnpy.PUSH)
push.connect(rep_address)
str1 = '{"category":["Main","Tasks"],"name":"Command-1","data":{}}'
push.send(str1)
time.sleep(1)
push.close()
After sending this Command-1 as a message, I send some Command-2 (with a format similar to the above code) to do something else with the robot. But, since the length of the two messages is different (for example the second message is shorter), there will be some unknown characters at the end of the second message when I send it and the robot does not recognize it.
I tried to solve this by adding a lot of spaces at the end of the second message line (because my messages are somehow considered as JSON), but it becomes intractable when the number of commands goes to around 10 (I also tried to make it smarter by comparing the length of each message with the maximum length of the messages being sent before that, and add extra spaces at the end of the message if it's shorter than the max, but still doesn't work all the time!).
So, I thought a better idea could be available for this issue. It seems that there is a buffer-like variable that the messages are being overwritten on that. If so, that could be resolved if I have access to that variable to clear it every time before sending a new message.
Please let me know if you think different, or you have any idea to resolve this issue.
Thanks
The text was updated successfully, but these errors were encountered: