Coder Social home page Coder Social logo

Comments (1)

jpliew avatar jpliew commented on May 14, 2024

@DiE-MaRMeLaDe due to differences in 32bit SAMD21 in M0 and 8bit 32U4 using int, you may be able to cast (uint8_t) in line 150 and 151 of WebUSB.cpp

D_ENDPOINT((uint8_t)USB_ENDPOINT_OUT(pluggedEndpoint),USB_ENDPOINT_TYPE_BULK,0x40,0),
D_ENDPOINT((uint8_t)USB_ENDPOINT_IN (pluggedEndpoint+1),USB_ENDPOINT_TYPE_BULK,0x40,0)

This will remove the -Wnarrowing error. However there should more error that was missed

C:\Users\JP\Documents\Arduino\libraries\WebUSB\WebUSB.cpp:164:42: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

    if (USB_SendControl(0, &landingPage, 1) < 0)

It will be really hard to get rid of this without major reworking on the M0 USBCore.cpp

uint32_t USBDeviceClass::sendControl(const void* _data, uint32_t len)
{
	const uint8_t *data = reinterpret_cast<const uint8_t *>(_data);
	uint32_t length = len;
	uint32_t sent = 0;
	uint32_t pos = 0;

	if (_dry_run == true)
		return length;

	if (_pack_message == true) {
		memcpy(&_pack_buffer[_pack_size], data, len);
		_pack_size += len;
		return length;
	}

 	while (len > 0)
 	{
		sent = armSend(EP0, data + pos, len);
		pos += sent;
		len -= sent;
 	}

	return length;
}

Above, you can see that in SAMD21's USBCore.cpp the command sendControl only returns unsigned number but in Leonardo sendControl has negative 1 number return that mean something

int USB_SendControl(u8 flags, const void* d, int len)
{
	int sent = len;
	const u8* data = (const u8*)d;
	bool pgm = flags & TRANSFER_PGM;
	while (len--)
	{
		u8 c = pgm ? pgm_read_byte(data++) : *data++;
		if (!SendControl(c))
			return -1;
	}
	return sent;
}

So, either you report a bug at Arduino M0's github or it will be easier and less stress to use another board that is listed here, since M0 is a retired product.

Hope this helps. If you think this answer your questions, please close this issue.

from arduino.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.