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

Serial reading issue(Corrupted input serial packets) #8

Closed
yarsanich opened this issue May 24, 2019 · 5 comments
Closed

Serial reading issue(Corrupted input serial packets) #8

yarsanich opened this issue May 24, 2019 · 5 comments

Comments

@yarsanich
Copy link
Collaborator

Following the first implementation of the microbit hub software, serial reading should be implemented by each byte.

Here dapjs was used for serial reading(https://github.com/Taylor-Woodcock/microbit-web-bridge/blob/master/public/javascripts/SerialHandler.ts#L38). dapjs serial reading implemented using clock approach(https://github.com/ARMmbed/dapjs/blob/master/src/daplink/index.ts#

Hub microbit produce messages regarding SLIP_* characters that have been used for writing to serial here.

If we start monitoring serial port we can see next

RAW webusb log
Received: ��/share/historicalData/0tnw3glcelsiuss��hare/hist
WebBridge.bundle.js:5261 Received: �ՂDATA SENT�lsius�nw3glcelsiuss�celsiuss��
WebBridge.bundle.js:5261 Received: �ik/share/historicalData/0tnw3glcelsiuss�lcelsius
WebBridge.bundle.js:5261 Received: �lc��SENT�oricalData/10tnw3glcelsius���/sha
WebBridge.bundle.js:5261 Received: �ik�DATA SENT�3glcelsiuss�^/share/historicalData/
WebBridge.bundle.js:5261 Received: ��/share/historicalData/0tnw3glcelsiuss��hare/hist
WebBridge.bundle.js:5261 Received: �ՂDATA SENT�lsius�nw3glcelsiuss�celsiuss��
WebBridge.bundle.js:5261 Received: �ik/share/historicalData/0tnw3glcelsiuss�lcelsius
WebBridge.bundle.js:5261 Received: �lc��SENT�oricalData/10tnw3glcelsius���/sha
WebBridge.bundle.js:5261 Received: �ik�DATA SENT�3glcelsiuss�^/share/historicalData/
WebBridge.bundle.js:5261 Received: ��/share/historicalData/0tnw3glcelsiuss��hare/hist
WebBridge.bundle.js:5261 Received: �ՂDATA SENT�lsius�nw3glcelsiuss�celsiuss��
WebBridge.bundle.js:5261 Received: �ik/share/historicalData/0tnw3glcelsiuss�lcelsius
WebBridge.bundle.js:5261 Received: �lc��SENT�oricalData/10tnw3glcelsius���/sha
WebBridge.bundle.js:5261 Received: �ik�DATA SENT�3glcelsiuss�^/share/historicalData/
WebBridge.bundle.js:5261 Received: ��/share/historicalData/0tnw3glcelsiuss��hare/hist
WebBridge.bundle.js:5261 Received: �ՂDATA SENT�lsius�nw3glcelsiuss�celsiuss��
WebBridge.bundle.js:5261 Received: �ik/share/historicalData/0tnw3glcelsiuss�lcelsius
WebBridge.bundle.js:5261 Received: �4�(/share/historicalData/9tnw3glcelsiuss����/sha

oricalData/28tnw7glcelsiussÀï./share/historicalDat - serial packet after dapJS.

@taylow
Copy link
Owner

taylow commented May 24, 2019

Thanks for posting the issue. It'll be good to have all of this in one place.

As for the implementation of a byte-by-byte read, I have looked into DAPLink's commands and have yet to find a single byte read. It appears DAPjs is sending the value 0x83 (READ) during the timer found at startSerialRead(). I was hoping there would be a similar value for reading a single byte.

I understand you have some alternate approaches than DAPjs. It will be interesting to see what you come up with.

@taylow
Copy link
Owner

taylow commented May 24, 2019

Actually, just thinking bout it, has anyone tried changing the serialDelay parameter passed into startSerialRead()? I'm wondering if slowing the timer in which the data is read would help as the data may be being processed before all data is available?

Another possible solution is that we implement the SLIP_* fully so that each command has a start and an end character. This way, we can fill a buffer with the incoming data until a SLIP_END character is found.

This would be as simple as appending the data to a buffer and only emitting the DAPLink.EVENT_SERIAL_DATA event when the buffer contains both the start and end characters.

@yarsanich
Copy link
Collaborator Author

@Taylor-Woodcock I tried lowering serial_delay value, but no-luck.

@yarsanich
Copy link
Collaborator Author

@Taylor-Woodcock your second suggestion is possible, but we need to fork dapJS then.

@yarsanich
Copy link
Collaborator Author

Received to write: ���^���DATA SENT�
WebBridge.bundle.js:5261 Received: ���^���DATA SENT�oricalData/�3�tnw3�gl�celsius���7�tnw3

additional logs

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

No branches or pull requests

2 participants